Saturday, 10 August 2013

iPhone: UITableViewCellSelectionStyleNone not working

iPhone: UITableViewCellSelectionStyleNone not working

Right now I am trying to change the color of the selected cell, but a
little weird thing is happening here. I have placed the two images. Please
take a look:
Here is what is happening. When I select the 'early' cell, it turns blue.
It moves to the 'early blah blah' viewController. Then hit the 'Find'
button, it goes back to the first view. It works, but the cell is still
selected blue! So I wrote some code as below:
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
if ([_currentMethod isEqual: @"searchIt"]) {
if (indexPath.row == 0) {
BookMark2ViewController* bookMark2 = [[BookMark2ViewController
alloc] init];
UITableViewCell* cell = [self tableView:_tableView
cellForRowAtIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
[self.navigationController pushViewController:bookMark2
animated:YES];
}else if (indexPath.row == 1) {
BookMarkViewController* bookMark1 = [[BookMarkViewController
alloc] init];
[self.navigationController pushViewController:bookMark1
animated:YES];
}
}
The two lines right in the middle of the code which is: UITableViewCell*
cell = [self tableView:_tableView cellForRowAtIndexPath:indexPath];
cell.selectionStyle = UITableViewCellSelectionStyleNone;
These two lines didn't work. Does any one know how to fix this? Thank you
for your time.

No comments:

Post a Comment