简体   繁体   中英

How to access UITableView from delegate?

When I dismiss a modal, I'm overriding viewWillAppear in order to make the table view in the view reload. The problem is that I don't have any pointer to the table view to call it to refresh. I've considered awkward solution such as storing it in a pointer when the tableview first loads and calls the UIViewController (the delegate) for each row, but it seems that there hast to be a pointer to it somewhere. Does anyone know how to get it?

It's very common for a viewController with a UITableView in it's view hierarchy (even as the root, in the case of a UITableViewController ) to keep a weak pointer to the UITableView for just this kind of thing.

If the UITableView is built in storyboard/xib , set it up as an IBOutlet , otherwise, build the UITableView in code, add it as a subview and assign a pointer to self.tableView .

viewWillAppear is a perfectly sensible place to say [self.tableView reloadData]

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM