In my viewWillAppear method I am trying to remove the cell accesory, in debug I开发者_开发知识库 hit this line, but still its not removed from screen, Any ideas where should I be doing this wrong? Cell is custom cell and I set this accesory first time in the cellForRowAtIndexPath method and later try to change in viewWillAppear when its navigating back from another page.
CustomCell *cell =(CustomCell*)[self.tableView cellForRowAtIndexPath:[NSIndexPath indexPathForRow:i inSection:0]];
cell.accessoryType = UITableViewCellAccessoryNone;
You should refrain from directly manipulating the display of UITableView elements outside of the UITableViewDelegate and UITableViewDatasource methods. Doing so undoes the encapsulation provided by those methods. Instead, I would recommend creating an instance variable in your ViewController that you can poll from within your delegate and datasource methods. For example, using a BOOL called showCellAccessory:
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self.tableView reloadData];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
// the usual cell dequeueing stuff here
if(showCellAccessory) {
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
} else {
cell.accessoryType = UITableViewCellAccessoryNone;
}
// more cell configuration stuff here
}
You can use delegation to send a message to this ViewController from the ViewController you are navigating back from:
- (void)dismissOtherViewController:(UIViewController)viewController {
showCellAccessory = NO;
[self.navigationController popViewControllerAnimated:YES];
}
Please try this one.....
UITableViewCell *x;
x=[tblProfileView cellForRowAtIndexPath:];
[x setAccessoryType:UITableViewCellAccessoryNone];
精彩评论