ios UI day01

来源:互联网 发布:程序员壁纸高清 编辑:程序博客网 时间:2024/05/02 04:25

1.NSObject 是所有类的父类


2.UIViewController 继承自UIResponder ,UIResponder继承自NSObject;

UIViewController是所有控制器的父类;


3.UIViewController是mvc中的Controller的作用,是沟通dataSource和view之间的桥梁


4.ViewController的声明周期

loadView:创建视图控制器

viewDidLoad:加载视图

viewWillAppear:视图加载前运行

viewWillDisAppear:视图消失前(被关闭或者覆盖的时候)运行

willRotateToInterfaceOrientation:duration: 开始旋转时运行

didRotateToInterfaceOrientation:旋转结束时运行


5.关于loadView和viewDidLoad 的区别:

loadView 在视图初始化的时候调用,应用开启后只能调用一次

viewDidLoad: 在每次进入一个视图的时候,都会调用.


6.strong 和weak关键字

strong 用来修饰强引用的属性

weak 用来修饰弱引用的属性


7.UITableViewController

1).返回table中的行数

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSINteger)section:{

return [self.array count];

}


2).分组的形式,一共返回多少组数据

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{


return 4;

}


//设置行高

-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSINdexPath *)indexPath{

return 60;

}


3).UITableView的点击事件

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

UIAlertView *alert = [[UIALertView alloc] initWithTitle:@"提示" message:@"this is a alertView" delegate:nil cancelButtonTitle:@"取消" otherButtonTitles:nil,nil];

[alert show];


}









0 0
原创粉丝点击