开发者

what is the difference between self.navigationController and delegate.navigationController

i can use

MyFirstAppDelegate *delegate = (MyFirstAppDelegate *)[[UIApplication sharedApplication] delegate];
[del开发者_StackOverflow中文版egate.navigationController popViewControllerAnimated:YES];

or

[self.navigationController popViewControllerAnimated:YES];

So what is the difference between both ?

Please answer me ......

Thanks in advance..


You use the first form when you are accessing the navigation controller from an object that is not a view controller controlled by the navigation controller. That form accesses the navigation controller via the object that owns it i.e. the application delegate. Since the application delegate can be easily called from anywhere in the program, it is a good place to park things than any object might need a reference to.

You use the second form from an view controller that is controlled by the navigation controllers. It will only work from a view controller that has been previously pushed onto the stack.


I assume that you have one navigation controller the code is executing in a view controller that is on that navigation stack.

If so, then they both access the same navigation controller and there is no difference between them.

Typically, you would use the second form.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜