我已经建造这样的方法:如何直接调用tableView方法?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//some table related stuff
}
但是我不能叫这个,所以我基本上复制和粘贴的整体功能,并更名为:
- (void)jumpCountry: (NSIndexPath *)indexPath {
//some table related stuff
}
,并通过调用此方法:
[self jumpCountry:countryIndex];
但是我的类看起来难看(而不是首选),因为它已经拿到了SAM两种方法。那么,我怎样才能直接调用初始方法(我知道它被分配给一个调用该方法的按钮)。我正在使用iOS6.1。基本上,我想直接调用的原因是我有另一个线程侦听通知(来自位置服务),一旦收到通知,应该更改表视图。通知本身已经在搜索NSIndexPath,所以不会有任何问题。
你为什么不能叫'的tableView:didSelectRowAtIndexPath方法:'? – Wain
编译器提供了一个错误“使用未声明的标识符didSelectRowAtIndexPath'” –
我不明白你的问题,你能说清楚吗?为什么不能从'didSelectRowAtIndexPath'调用'[self jumpCountry:countryIndex];',而不是重复代码? –