美文网首页
使用IOS的方法

使用IOS的方法

作者: 你瞅誰 | 来源:发表于2015-12-10 17:15 被阅读144次
在IOS中方法名特别长,但是特别易读
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   }
自定义方法名
  • 一个参数
-(void)setImage:(NSString *)imageName;

  • 两个参数
-(void)setImage:(NSString *)imageName scale:(int)scl;

方法名:setImage, 类型:NSString, 型参:imageName

"void"代表没有返回值

  • 与xib连接的方法
    -(IBAction)clickBtn:(id)sender{ //点击事件的方法 }

  • 有返回值的方法
    -(void)setImage{self image = [UIImage imageNamed:@""];}
    必须return
  • 方法前+,-号的区别

+ 类方法 [类名 方法名]调用

UIView *topView.("+"方法) = UIView.new; 

- 对象方法 [实例对象 方法名]调用

UIView.`("-"方法)` = UIView.new;

相关文章

网友评论

      本文标题:使用IOS的方法

      本文链接:https://www.haomeiwen.com/subject/sblyhttx.html