我创建了一个名为_tableView的UItableView
,这里是view.m中表格 View 的代码
- (void)viewDidLoad
{
[super viewDidLoad];
tableData = [NSArray arrayWithObjects:@"Team Members",@"MembershipStatus",@"relation of status",@"Registerd events", nil];
[_tableView setUserInteractionEnabled:TRUE];
[_tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [tableData count];
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 54;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
[newCell setUserInteractionEnabled:TRUE];
newCell.textLabel.text = [tableData objectAtIndex:indexPath.row];
return newCell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"id");
}
在执行代码时我正确地得到了表格。但是当我选择其中一个列表项时,它不会响应。 (即 NSLog 不工作)。我错过了什么 ??或者我做错了什么??
最佳答案
在你的 -viewDidLoad
中写:
[_tableView setDelegate:self];
关于ios - UITableView 不响应 UITableViewCell 的选择,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20279546/