在cell.h声明一个protocol.
@proDelegate
-(v)someProMethod:(integer)cellRow;
@end
且声明属性
@property(xx,xx) id
@property(xx,xx) interger cellRow;
button点击事件方法里
-(v)btnClicked:(id)sender
{
if(_customDelegate != nil && [_customDelegate responseToSelector:@selector(someProMethod:)])
{
[_customDelegate someProMethod:cellRow];
}
}
在加载tableview的viewController someVC中,
someVC.h
#import "xxxCell.h"
@class SomeVC:ViewController
@implementation
-(cell *)cellForRow....
{
cell = ...
cell.dataSource = self;
cell.delegate = self;
//因为已经有delegate了,所以你定义的委托取其他名称,如customDelegate
cell.customDelegate = self;
cell.cellRow = indexPath.row;
}
//实现委托方法
-(v)someProMethod:cellRow
{
//跳转页面。需要可以在这个方法里传cell.row参数。
if(cellRow = 7)
{
//点击了第7行的按钮
}
}
@end