deselectrowatindexpath文字突出显示

时间:2014-05-15 12:35:39

标签: ios objective-c uitableview ios7

我将detailTextLabel的{​​{1}}设置为UITableViewCell

highlighted:YES;

但是- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [self.tableView deselectRowAtIndexPath:indexPath animated:YES]; UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath]; [cell.detailTextLabel setHighlighted:YES]; } 因为什么原因正在摧毁我deselectRowAtIndexPath:indexPath的突出显示?!

更新:

detailTextLabel

}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.row != 0)
{

    if(CellIsSelected)
    {
        UITableViewCell *cell = [tableView cellForRowAtIndexPath:selectedIndexPath];
        [cell.detailTextLabel setHighlighted:NO];
    }

    [self.tableView beginUpdates];

    if ([self datePickerIsShown] && (self.datePickerIndexPath.row - 1 == indexPath.row)){

        [self hideExistingPicker];

    }else {

        NSIndexPath *newPickerIndexPath = [self calculateIndexPathForNewPicker:indexPath];

        if ([self datePickerIsShown]){

            [self hideExistingPicker];

            selectedIndexPath = indexPath;

            if (newPickerIndexPath.row == 2)
                selectedIndexPath = [NSIndexPath indexPathForRow:2 inSection:indexPath.section];
            else if (newPickerIndexPath.row == 3)
                selectedIndexPath = [NSIndexPath indexPathForRow:1 inSection:indexPath.section];

        }
        else
            selectedIndexPath = indexPath;

        [self showNewPickerAtIndex:newPickerIndexPath];

        self.datePickerIndexPath = [NSIndexPath indexPathForRow:newPickerIndexPath.row + 1 inSection:0];

    }

    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];

    [self.tableView endUpdates];

    CellIsSelected = YES;

    [picker reloadAllComponents];


}

1 个答案:

答案 0 :(得分:1)

以下是满足您要求的一种方式 我发布示例代码在新项目中试试这个,试试希望这有助于你

<{1>}文件中的

ViewController.h
<{1>}文件中的

#import <UIKit/UIKit.h>

@interface ViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>
@property (nonatomic,retain)NSIndexPath *selectedIndexPath;
@end

输出就像下面的那样

enter image description here

编辑您的代码

ViewController.m