IBOutlet和IBAction

用IBoutlet 和IBaction修饰的字段或方法都和InterfaceBuilder有关。 
IBoutlet修饰的字段可以和InterfaceBuilder里相应控件相关联; 
IBaction修饰的方法可以和InterfaceBuilder里控件的相应动作相关联。

需要注意的是,任何一个被声明为IBOutlet并且在Interface Builder里被连接到一个UI组件的成员变量,会被额外retain一次。 

Java代码  收藏代码
  1. IBOutlet UILabel *label;  



这个label在Interface Builder里被连接到一个UILabel。此时,这个label的retainCount为2。 
所以,只要使用了IBOutlet变量,一定需要在dealloc或者viewDidUnload里release这个变量。 

posted @ 2016-03-24 12:13  JessicZeng  阅读(116)  评论(0)    收藏  举报