iPhone UITableView cells stay selected

前端 未结 7 1191
[愿得一人]
[愿得一人] 2020-12-28 11:50

in my UITableView sometimes cells stay selected after touching. Because it happens only occasionally, I\'m not able to reproduce the problem.

Any hints? Maybe it has

7条回答
  •  隐瞒了意图╮
    2020-12-28 12:42

    Just to expand on "Ed Marty"s answer, I chose to add the deselect in the "viewWillDisappear" method instead because I thought that it looked nicer.

    In addition to this I was using a UITableView with a regular UIViewController (rather than a UITableViewController) so the tableView variable wasn't available to me. To overcome this I added a tableView property in my view controllers header file (and in my XIB file I connected the actual table view to the property)...

    @property (nonatomic,retain) IBOutlet UITableView *tableView
    

    ...and in the view controllers implementation wired up the property and performed the deselect as follows..

    @synthesize tableView
    
    - (void) viewWillDisappear:(BOOL)animated {
        [self.tableView deselectRowAtIndexPath:[self.tableView indexPathForSelectedRow] animated:animated];
        [super viewWillDisappear:animated];
    }
    

提交回复
热议问题