开发者

iPhone: How to remove UITableViewCellAccessory

开发者 https://www.devze.com 2023-03-28 10:05 出处:网络
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? Cel

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]; 
0

精彩评论

暂无评论...
验证码 换一张
取 消