IOS 委托小例

来源:互联网 发布:java自带的md5加密 编辑:程序博客网 时间:2024/05/22 02:08
     A类委托B类:

     1)新建一个协议 changeRowDelegate  包含一个方法    -(void)changeRow;


     2)在A类增加@property(nonatomic,assign)id<
changeRowDelegate > delegate  , 在A类需要的地方 [delegate changeRow];

     3)  在B类实例化A类 ,设置A类的代理为自己,最后实现协议方法 今天就是忘了设置代理为自己,发帖纪录下!

            A *a = [[A alloc]init];
            a.delegate = self 
            -(void)changeRow{
                    .......
            } 


       再写个刷新某一行的方法
        
         
NSIndexPath *indexPath_1=[NSIndexPath indexPathForRow:1inSection:0];

NSArray *indexArray=[NSArrayarrayWithObject:indexPath_1];

[regTableView reloadRowsAtIndexPaths:indexArraywithRowAnimation:UITableViewRowAnimationAutomatic];

        
 

原创粉丝点击