iOS uses navigationcontroller frequently occurring problems

Source: Internet
Author: User

Situation One:

Myviewcontroller*sampleviewcontroller = [ [[ myviewcontroller Alloc]initwithxxx] autorelease];       

[self. navigationcontroller   Span style= "line-height:1.5" >pushviewcontroller : SAMPLEVIEWCONTROLLER  animated : true ];

BUG: No interface reaction

Analyze possible causes of errors:

1: self. navigationcontroller is nil, Null pointer execution pushviewcontroller skip directly, then sampleviewcontroller will be released, so the interface will not react.

    self. navigationcontroller navigationcontroller is a property inherited by the Uiviewcontroller parent class, and is not used casually, unless you are currently viewcontroller in by NAV push. Or use xib/code to make Navigationcontroller root, Cocoa's code should be assigned to the value. (Off-topic, I have a lot of interface is a partial use of a viewcontroller, this case the Viewcontroller nav is empty, if you want to use correctly, you can take from the app, you can assign values, you can take the whole interface ... I want to take it all.

2, self. navigationCo Ntroller is nil and the interface hangs

If you Sampleviewcontroller uses the network asynchronous request, when the initwithxxx will go to fetch the number, then you 10 89 will hang off.

Reason analysis: Everyone network requests, often as follows:

twitterclient *twitterclient = [[twitterclient Alloc] Initwithtarget: Self Action:@selector(xxxreceive:obj:)];

[twitterclient getXXX:p Aram];

Congratulations, this situation is not navigationcontroller is empty, your program is very easy to hang up, because the network request we will be asynchronous to pull the data, when the data back, will be recalled to this class of xxxreceive:obj method,

but what if the interface exits and the data is received? That is not a null pointer call,twitterclient Record of the need to callback memory address on the god horse situation can be, callback: It's a cup.

Workaround: Twitterclient is made a member, when the destruction of the time to clean up twitterclient, just clean up.


3, self. navigationcontroller to nil , the interface hangs

     same as above twitterclient member, dealloc also clean up the scene, or hang up

cause Analysis: An asynchronous problem, Twitterclient has already taken the data, but Sampleviewcontroller has been released, but Dealloc never had time to come in ...

workaround, 1: Make sure NAV is correct, 2: try to interface Viewdidload When the network request data, in dispear time to clean up the network.


Situation Two:

Reason: ' Pushing a navigation controller is not supported '

The reason for the above error is:

As you know, you can push the Viewcontroller into a navigationcontroller. It's like a stack operation!

When you push a navigationcontroller to Navigationcontroller again, an error occurs.

reason: ' Pushing a navigation controller is not supported ' the error.

It should be that Navigationcontroller does not support push in the object is Navigationcontroller bar.


The Modification method is: the page that will be entered does not inherit the UI Navigationcontroller


Situation Three:

Sometimes in the project there will be a message push, that is, pop-up prompts the user message, and the message with a link, when you click on the connection can not jump,

This is due to your SELF.NAvigationcontroller = nil.

Because the controller you're playing with the window is not wrapped in UInavigationcontroller .



iOS uses navigationcontroller frequently occurring problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.