UIViewController

2016-02-23  本文已影响0人  焦六金Jxx

1.根视图

RootViewController *rootVC = [[RootViewController alloc] init];

self.window.rootViewController = rootVC;

[rootVC release];

添加图片

相对路径修改之后仍然可以正常显示

绝对路径如果文件位置修改那么就找不到了

imageView.image = [UIImage imageNamed:@"%%%FKP[A6RT}ZHB8[CNA[8W.jpg"];

获取路径(动态变化的绝对路径)

参数1.文件名

参数2.文件后缀

2.导航视图控制器   UINavigationController

标题

背景颜色

设置不透明     navigationController.navigationBar.translucent    NO

隐藏方式 :

1.navigationBarHidden                    YES

2.navigationBar.hidden                    YES

样式   self.navigationController.navigationBar.barStyle                  UIBarStyleBlack

修改导航栏上内容的颜色   self.navigationController.navigationBar.tintColor         UIColor whiteColor

左右按钮     self.navigationItem.leftBarButtonItem = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCamera target:self action:@selector(left:)] autorelease];

创建导航视图控制器

MainViewController *mainVC = [[MainViewController alloc]init];

UINavigationController *naVC = [[UINavigationController alloc]initWithRootViewController:mainVC];

self.window.rootViewController = naVC;

[mainVC release];

[naVC release];

触发事件进入下一页

[self.navigationController pushViewController:secVC animated:YES];

协议传值

从后向前传值

协议传值__SecondViewController.h

1.声明一份协议

@protocol SecondViewControllerDelegate//协议方法

-(void)changeValue:(NSString *)value;

@end

@interface SecondViewController : UIViewController

2.设置代理人的属性

@property(nonatomic,assign)iddelegate;

@end

协议传值__SecondViewController.m

3.设置代理人执行的协议方法--写在需要执行事件方法里

-(void)click:(UIButton *)button{

[self.delegate changeValue:self.textField.text];

}

协议传值__MainViewController.m

4.签订协议

@interface MainViewController ()

5.设置代理人对象

secVC.delegate = self;

6.实现协议方法

-(void)changeValue:(NSString *)str{

}

属性传值

从前向后传值

属性传值__SecondViewController.h

1.在第二个页面写一条属性

@property(nonatomic,assign)NSInteger number;

针对字符串写一条属性

@property(nonatomic,copy)NSString *str;

@property(nonatomic,retain)NSArray *arr;

属性传值__MainViewController.h

2.属性传值的第二步

-(void)click:(UIButton *)button{

SecondViewController *secVC = [[SecondViewController alloc] init];

secVC.number = 100;

secVC.str = self.myTextField.text;

secVC.arr = @[@"a",@"b"];

[secVC release];

}

   

 

上一篇下一篇

猜你喜欢

热点阅读