- 在ios中系统方法名非常长,但是易读
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- 那么我们来自定义方法
- 一个方法名的方法
-(void)setImage
:(NSString *)imageName; - 两个方法名的方法
-(void)setImage
:(NSString *)imageName
scale
:(int)scl; - 方法名为
setImage
,setImage
/scale
,剩下的为形参。 - void代表没有返回值(返回值可以是任意类型)
- 有返回值的方法-(void)setImage{
最后必须return;
- -(IBAction)clickBtn:(id)sender{
// 点击事件的方法
} - IBAction是与xib沟通的桥梁,只有写它才能连接xib。
- 方法前-,+号的区别
- +:类方法 [类名 方法名]调用
- -:对象放方法 [实例对象 方法名]调用
UIView *topView = UIView.new;
星后面的就为对象 - UIView.new;为+号方法
- topView.new;为-号方法