Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

interact the navigation controller bar button with embed container view

enter image description here

I've created a UIViewController, and insert a container view in it, which embed a UITableViewController. As the image described above.

When user click the Table View Cell, I'd like to add a UIBarButton on the Navigation bar.

But, how can I manage this? I can rise the DatePicker when click on Table View Cell, but when I call self.presentingViewController in table view controller implementation file, it returns (null), same as when I call self.parentViewController

like image 692
Daniel Chen Avatar asked Aug 17 '26 15:08

Daniel Chen


1 Answers

You're probably trying to access the parent controller too early. If you log self.parentViewController in viewDidLoad, it will return null, but it should return the correct controller from viewDidAppear, and certainly from the didSelectRowAtIndexPath method. Using parentViewController in this context is correct, not presentingViewController.

like image 193
rdelmar Avatar answered Aug 19 '26 06:08

rdelmar



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!