我的 iPhone 应用程序上有一个工作表视图,并且正在使用 navigationController 实现第二个视图。
但是,当我尝试在初始视图上选择一个单元格时,它没有响应,即没有蓝色突出显示,没有选择。
任何人都可以建议我可能错过了什么,或者当用户点击单元格时负责实际选择单元格的是什么?
好的,谢谢您的建议 - 仍然没有运气。这是我的代码:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]autorelease];
[cell setSelectionStyle: UITableViewCellSelectionStyleBlue];
UIView *selectionView = [[[UIView alloc] init] autorelease];
selectionView.backgroundColor =[UIColor redColor];
cell.selectedBackgroundView = selectionView;
}
// format text
cell.textLabel.font = [UIFont fontWithName:@"Arial" size:12];
cell.textLabel.text = [tableArray objectAtIndex:indexPath.row];
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//NSUInteger row = indexPath.row;
//[DetailView …Run Code Online (Sandbox Code Playgroud)