Iphone 无法选择单元格,但我可以设置textLabel

Iphone 无法选择单元格,但我可以设置textLabel,iphone,iphone-sdk-3.0,uitableview,Iphone,Iphone Sdk 3.0,Uitableview,我只想选择我的第一部分的第一个单元格,这很简单,但它不想工作 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"CellIdentifier"; // Dequeue or create a cell of the appropriate type.

我只想选择我的第一部分的第一个单元格,这很简单,但它不想工作

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    static NSString *CellIdentifier = @"CellIdentifier";

    // Dequeue or create a cell of the appropriate type.
    UITableViewCell *cell;
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    cell.accessoryType = UITableViewCellAccessoryNone;
    cell.textLabel.font = [UIFont boldSystemFontOfSize:17];
    cell.selectionStyle = UITableViewCellSelectionStyleBlue;


    switch (indexPath.section) {
        case 0:
        {
            NSString *cellIconName = [[self subViewIconNames] objectAtIndex:[indexPath row]];   
            UIImage *cellIcon = [UIImage imageNamed:cellIconName];
            [[cell imageView] setImage:cellIcon];
            cell.imageView.alpha = 0.5;
            cell.textLabel.textColor = [UIColor grayColor];
            cell.textLabel.text = [self.subViewNames objectAtIndex:indexPath.row];


            if ([MyAppDelegate sharedAppDelegate].inSubView) {
                    cell.userInteractionEnabled = NO;
                if (indexPath.row == 0) {
                    firstIndexPath  =indexPath;
                    cell.selected = YES;
                    cell.textLabel.text = @"yes this changes";
                }
            }



            break;
        }
...
所以textlabel变为“yes this changes”,但选择了no

我尝试了不同的方法,在重新加载之后:

NSIndexPath *ip=[NSIndexPath indexPathForRow:0 inSection:0];
        [[MyAppDelegate sharedAppDelegate].rootViewController.tableView  selectRowAtIndexPath:ip animated:YES scrollPosition:UITableViewScrollPositionBottom];

我不知道去哪里找。。。请提供帮助

我不确定您想做什么,但可能您应该尝试使用突出显示,除了所选的:

cell.selected = YES;
cell.highlighted = YES;

试着这样做:

- (void) tableView:(UITableView *)tableView selectAndScrollToIndexPath:(NSIndexPath *)newSelectionIndexPath {

    [tableView selectRowAtIndexPath:newSelectionIndexPath animated:NO scrollPosition:UITableViewScrollPositionNone];
    [[tableView cellForRowAtIndexPath:newSelectionIndexPath] setSelected:YES animated:NO];

    [tableView scrollToRowAtIndexPath:newSelectionIndexPath atScrollPosition:UITableViewScrollPositionMiddle animated:NO];
}

不,它仍然没有被选中。。。非常奇怪您是否尝试使用此setter[单元格setSelected:YES动画:YES]?