`

OC 学习备忘

    博客分类:
  • oc
 
阅读更多
1:居中布局

label.center = CGPointMake(CGRectGetMidX(window.bounds), CGRectGetMidY(window.bounds));

2:设备检测
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
        return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
    } else {
        return YES;
    }

3:UISegmentedControl 组件
 NSArray *buttonNames = [NSArray arrayWithObjects:
                            @"One", @"Two", @"Three", @"Four", @"Five", @"Six", nil];
    UISegmentedControl* segmentedControl = [[UISegmentedControl alloc] initWithItems:buttonNames];
    segmentedControl.segmentedControlStyle = UISegmentedControlStyleBar;
    segmentedControl.momentary = YES;
    [segmentedControl addTarget:self action:@selector(segmentAction:) 
               forControlEvents:UIControlEventValueChanged];

4:通过代码获取stroyBoard
NSString *sourceName = IS_IPAD ? @"Modal~iPad" : @"MySB";
    UIStoryboard *sb = [UIStoryboard storyboardWithName:sourceName bundle:[NSBundle mainBundle]];
    UINavigationController *navController = [sb instantiateViewControllerWithIdentifier:@"infoNavigationController”];

 

分享到:
评论

相关推荐

    OC编程之道ios设计模式源码

    通过深入学习并实践这些设计模式,开发者可以更好地组织代码,提高代码的可读性和可维护性,同时也能提升开发效率,降低项目风险。《OC编程之道:iOS设计模式源码》正是这样一个宝贵的资源,提供了丰富的实践案例,...

    swift-使用OC实现常用的23种设计模式

    Swift,作为Apple的开源编程语言,虽然原生支持面向协议编程,但仍然可以从Objective-C(OC)中学习并应用23种经典的设计模式。这些模式对于提高代码的可读性、可维护性和复用性具有重要意义。在Swift中,通过理解并...

    ios设计模式开发23种设计模式OC编程

    本资源“ios设计模式开发23种设计模式OC编程”提供了Objective-C(OC)语言实现的全部23种经典设计模式的实例,可以直接在Xcode项目中导入使用。下面我们将详细探讨这23种设计模式及其在iOS开发中的应用。 1. **...

    CPSystemPermissionsManager.zip

    这个库可能是用Objective-C(OC)编写的,因为它被打上了"oc 系统权限"的标签。 首先,我们来深入理解这些权限的重要性: 1. **蓝牙权限**:如果应用需要与其它设备进行蓝牙通信,例如传输数据或控制智能硬件,就...

    docker私有库的搭建实现

    安装部署一个私有的Docker Registry是引入、学习和使用Docker这门技术的必经之路之一。尤其是当Docker被所在组织接受,更多人、项目和产品开始接触和使用Docker时,存储和分发自制的Docker image便成了刚需。Docker ...

Global site tag (gtag.js) - Google Analytics