标签:style blog io ar color os sp for strong
六:获得另一个控件器,并实现跳转
UIStoryboard* mainStoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil]; UIViewController *registerViewController = [mainStoryboard instantiateViewControllerWithIdentifier:@"registerViewController"]; registerViewController.modalTransitionStyle = UIModalTransitionStyleCoverVertical; [self presentViewController:registerViewController animated:YES completion:^{ NSLog(@"Present Modal View"); }];
其中registerViewController是第二个视图中标识检查器Storyboard ID的值
七:判断IOS版本
判断IOS是不是7.0以后的
if([[[UIDevice currentDevice] systemVersion] floatValue]>=7.0) {
}
八:Button不同状态下背景图片
[_registerButton setBackgroundImage:[UIImage imageNamed:@"3signbutton-n.png"] forState:UIControlStateNormal];
[_registerButton setBackgroundImage:[UIImage imageNamed:@"3signbutton-s.png"] forState:UIControlStateHighlighted];
九:判断设备是3.5寸还是4寸
if ([[UIScreen mainScreen] currentMode].size.height == 480||[[UIScreenmainScreen] currentMode].size.height == 960)
{
//这是3.5寸的iPhone设备
}
else
{ //这是4寸的iPhone设备 }
十:viewDidLoad中调用
无论你是通过xib文件还是重写loadView方法创建UIViewController的view,在view创建完毕后,最终都会调用viewDidLoad方法,一般我们会在这里做界面上的初始化操作,比如往view中添加一些子视图、从数据库或者网络加载模型数据装配到子视图中
- (void)viewDidLoad { [super viewDidLoad]; // 添加一个按钮 UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd]; [button addTarget:self action:@selector(click) forControlEvents:UIControlEventTouchUpInside]; [self.view addSubview:button]; }
十一:树形结构导航问题(UINavigationController)
1:如何修改第二页的返回back文字
应该在第一页的viewDidLoad里面进行修改(假设从A界面push到B界面,希望改变B界面的返回按钮标题,则在A界面中加入代码),代码如下:
-(void)viewDidLoad { UIBarButtonItem *backItem = [[[UIBarButtonItem alloc] init] autorelease]; backItem.title = @"返回"; self.navigationItem.backBarButtonItem = backItem; }
2:如何增加一个控件在标头
在本页的viewDidLoad里面进行增加;代码如下:
-(void)viewDidLoad { UIBarButtonItem* Done=[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:@selector(DownShow)]; self.navigationItem.rightBarButtonItem=Done; } -(void)DownShow { }
其中按键类型如下(带有不同的图标):
UIBarButtonSystemItemDone, UIBarButtonSystemItemCancel, UIBarButtonSystemItemEdit, UIBarButtonSystemItemSave, UIBarButtonSystemItemAdd, UIBarButtonSystemItemFlexibleSpace, UIBarButtonSystemItemFixedSpace, UIBarButtonSystemItemCompose, UIBarButtonSystemItemReply, UIBarButtonSystemItemAction, UIBarButtonSystemItemOrganize, UIBarButtonSystemItemBookmarks, UIBarButtonSystemItemSearch, UIBarButtonSystemItemRefresh, UIBarButtonSystemItemStop, UIBarButtonSystemItemCamera, UIBarButtonSystemItemTrash, UIBarButtonSystemItemPlay, UIBarButtonSystemItemPause, UIBarButtonSystemItemRewind, UIBarButtonSystemItemFastForward, UIBarButtonSystemItemUndo, UIBarButtonSystemItemRedo, UIBarButtonSystemItemPageCurl//只能在ToolBar上显示
3:如何修改标头的色彩
self.navigationController.navigationBar.tintColor=[UIColor redColor];
4:增加其它UISegment,UISwith控件
在本页viewDidLoad中增加如下代码,
UISegmentedControl *mySegment; mySegment = [[UISegmentedControl alloc] initWithFrame:CGRectMake(218.0f, 8.0, 100.0f, 30.0f)]; [mySegment insertSegmentWithTitle:@"分配" atIndex:0 animated:YES]; [mySegment insertSegmentWithTitle:@"处理" atIndex:1 animated:YES]; mySegment.segmentedControlStyle = UISegmentedControlStyleBar; mySegment.selectedSegmentIndex = 0; [self.navigationController.navigationBar addSubview:mySegment];
标签:style blog io ar color os sp for strong
原文地址:http://www.cnblogs.com/wujy/p/4123779.html