@property(nonatomic,strong) UILabel* lable;
- (void)viewDidLoad {
[super viewDidLoad];
//懒加载:延时加载,即用到的时候才会去加载(效率低,占用内存小)需要注意:访问属性的时候必须用打点调用懒加载就是get方法
self.lable.text= @"懒加载";
}
//懒加载控件
- (UILabel*) lable{
//要判断是否存在
if(!_lable) {
//当不存在的时候去创建
_lable= [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 100, 30)];
[self.view addSubview:_lable];
}
//存在就直接返回
return _lable;
}
- (void)touchesBegan:(NSSet*)touches withEvent:(UIEvent*)event {
oneViewController* vc =[[oneViewController alloc] init];
[self presentViewController:vc animated:YES completion:nil];
self.lable.text=@"111";
}