New instance of a UIViewController within another UIViewController: Why can't I set an instance variable?

∥☆過路亽.° 提交于 2019-12-06 11:35:50

You cant set any view related values like this(making object and set other enteries from that view).

Because you can't set any level's value before viewDidLoad of any view controller.What you need, you need set properties of string type for labels accordingly and set their values in MyTabBarViewController then from the stack pick up the object of the MyTabBarViewController class in PhotoViewController and then access it's properties and set your labels.

For picking the view object from stack you need to use this line

MyTabBarViewController *obj = (MyTabBarViewController *)[self.navigationController.viewControllers objectAtIndex: [self.navigationController.viewControllers count]-2];

The IBOutlet entities don't exist until viewDidLoad, and that doesn't generally happen until you initiate a show. Therefore, in MyTabBarViewController you're addressing a label, et al, that doesn't exist. (Of course, Objective-C conveniently ignores calls on nil pointers, so it SEEMS like it all works -- just nothing happens.)

According to the spec, you can trigger loading by referring to the view property of the view controller, but I've never tried it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!