开发者

Separate UITableView Controller/Delegate Reference Quandary

开发者 https://www.devze.com 2023-02-26 05:17 出处:网络
I\'ve been following the guide in the following (StackOverflow question), which has been very helpful, and by completing the steps I\'ve managed to successfully have a UITableView with a separate cont

I've been following the guide in the following (StackOverflow question), which has been very helpful, and by completing the steps I've managed to successfully have a UITableView with a separate controller and delegate/datasource.

However, even though everything is working, I'm unable to reference or change anything instance of the UITableview.

For example: let's say the UIViewController for the table is TableViewController and the separate delegate/datasource class is TableDelegate. I have everything hooked up in interface builder as in the previous SO question. In TableDelegate.m, within viewDidLoad, I put the following:

self.navigationItem.leftBarButtonItem = 开发者_如何学Cself.editButtonItem;

And nothing changes in the UITableView as it should. This includes pushing UIViewControllers, which also has no effect as if the code wasn't even there, although when I NSLog(), it appears it is being run.

The odd part, however, is that even though that doesn't work, if I set the table's alpha property to 0, it works.

Thanks for any help in advance, let me know if you need any more information to solve the problem.


From your comments, it looks like both TableViewController and TableDelegate are subclasses of UIViewController. If this is the case, make sure both are being added to the navigation stack by pushing them onto a UINavigationController or adding them to a UITabBarController: otherwise, viewDidLoad may not be called.

As an aside, I don't think it's a good idea to have your UITableViewDataSource be a UIViewController subclass when you've already got a UITableViewController to handle that table view.

0

精彩评论

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