Wil*_*sen 7 iphone objective-c uitableview ios
我刚开始使用tableViews,我在navigationController中嵌入的viewController中的tableview中有5个单元格.当按下一个单元格时,另一个视图被推入.我的问题是我按下的单元格被选中,但选择不会消失.我尝试过这段代码:
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.tableView deselectRowAtIndexPath:indexPath animated:NO];
NewViewController *newViewController = [[NewViewController alloc] init];
newViewController.theTitle = [self.tableView cellForRowAtIndexPath:indexPath].textLabel.text;
[self.navigationController pushViewController: newViewController animated:YES];
}
Run Code Online (Sandbox Code Playgroud)
tableView在viewDidLoad方法中初始化.
仍然当我单击一个单元格时,新的viewController被推入但单元格保持选中状态.这可能是什么问题?
Ste*_*eve 33
您已将代码放在didDeselectRowAtIndexPath中 - 将其放在didSelectRowAtIndexPath中.这是一个容易犯的错误,因为在didSelect之前,didDeselect出现在代码完成中.
| 归档时间: |
|
| 查看次数: |
4798 次 |
| 最近记录: |