我有一个这样构造的方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
//some table related stuff
}
但是我无法调用此函数,因此我基本上复制并粘贴了整个函数,并将其重命名为:
- (void)jumpCountry: (NSIndexPath *)indexPath {
//some table related stuff
}
并使用以下方法调用此方法:
[self jumpCountry:countryIndex];
但是我的课看起来很丑陋(不是首选),因为它具有相同的两种方法。因此,如何直接调用初始方法(我知道它已分配给调用该方法的按钮)。我正在使用iOS6.1。基本上,我想直接调用的原因是我有另一个线程(从定位服务)监听通知,一旦收到通知,就应该更改表视图。通知本身已经在搜索NSIndexPath,因此不会有任何问题。
最佳答案
你可以放
[self jumpCountry:countryIndex];
对你的方法:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
关于ios - 如何直接调用tableView方法?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/17917388/