我是 iOS 新手。
我想使用 Today 扩展。我已经创建了 Today 扩展并添加了 uitableview 它工作正常。但是当我尝试选择行时,委托方法DidSelectRowAtIndexPath不会调用。
在我的代码中有 uitableview 委托和数据源的 3 种方法。
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"MyIdentifier"];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"MyIdentifier"];
}
cell.textLabel.text = [NSString stringWithFormat:@"Hello World%li",(long)indexPath.row];
return cell;
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
以上数据源方法调用正确
但是在选择行后不会调用 didselect 行方法。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"row Selected");
}
感谢您的帮助。