Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Mockup & CodeGen, iPhone & iPad
($9.99)

Make your own iPhone apps
and run them live!
(free)

Manu
($0.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-15-2009, 02:50 PM   #1 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 26
Default pop 2 views from navigation controller stack problem

Hello, I'm using a navigation bar on which I push several views according to what the user selects. At certain point I need to pop 2 views from the stack. (I need to go from view 3 to view 1 - it's not the root view, it`s just to explain my problem)

I`ve tried using the method "popToViewController:" in many ways, but I can't make it work

Then I decided to try another approach, making 2 pops simultaneously from the navigation stack. One from view 3 and the other at view 2 in the "viewWillAppear" method (under a specific condition, so that it doesn't pop every time it loads the view).

The app pops to the view I want (view 1), but the navigation items (title, back button, add button) are the ones of the 2nd view, not the 1st.

I've moved the declaration of the segmented control and add button al the view 1 from the viewDidLoadMethod to the viewWillApear, I debug it and it runs the code, but it still displays the wrong information at the navigation bar.

Any help will be appreciated.

Thanks!
fede is offline   Reply With Quote
Old 10-15-2009, 03:11 PM   #2 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Im not sure what you've tried, and what you haven't tried.. I am taking a stab here and guessing, based on your descriptions, but what I might try would be to put a method in view controller 1

Code:
-(void)popNavControllerToSelf{
  [self.navigationController popToViewController:self animated:YES];
}
then, in view 3, you can call...
Code:
[firstViewController popNavControllerToSelf];
See if the helps.
Dutch is offline   Reply With Quote
Old 10-15-2009, 03:25 PM   #3 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 26
Default

Thanks for the quick reply. I've tried it, but I get the same problem, it pops to the view I want, but the navigation bar still displays the info of the second view.

I really donīt understand why this happens. Do I have to unload the navigation bar items somewhere, or that is not necessary?
fede is offline   Reply With Quote
Old 10-15-2009, 03:26 PM   #4 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

Quote:
Originally Posted by fede View Post
Thanks for the quick reply. I've tried it, but I get the same problem, it pops to the view I want, but the navigation bar still displays the info of the second view.

I really donīt understand why this happens. Do I have to unload the navigation bar items somewhere, or that is not necessary?
I've never had to do that... that's really strange... let me chew on it for a few.
Dutch is offline   Reply With Quote
Old 10-15-2009, 04:46 PM   #5 (permalink)
Registered Member
 
Join Date: Nov 2008
Posts: 792
Default

I've ran into this some times. Its the animation. Until the first pop finishes you can't pop again or the nav bar buttons will bug on you. Change the second pop to viewDidAppear and see if it helps. This way it will pop back and pop again one animation at a time.
If you need to pop straight to the right controller you can try
Code:
int count = [self.navigationController.viewControllers count];
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-2]];
nobre84 is offline   Reply With Quote
Old 10-15-2009, 04:57 PM   #6 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 26
Default

Quote:
Originally Posted by nobre84 View Post
I've ran into this some times. Its the animation. Until the first pop finishes you can't pop again or the nav bar buttons will bug on you. Change the second pop to viewDidAppear and see if it helps. This way it will pop back and pop again one animation at a time.
If you need to pop straight to the right controller you can try
Code:
int count = [self.navigationController.viewControllers count];
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-2]];
Thanks a lot nobre!!! I changed the second pop to viewWillAppear and it worked perfectly!!

Thanks Dutch also for the response!!
fede is offline   Reply With Quote
Old 10-16-2009, 04:40 PM   #7 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 26
Default

I have a new problem related to this, though I think it has nothing to do with the pops.
On the first view I have a mutable array with Person information, and for each cell I load a nib and display the information of each element of the array.
On the 3rd view, when I delete an element of the array, I make the 2 pops, but sometimes the app crashes when it tries to load the 1st view and it gives me this message:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[UISegmentedControl nick]: unrecognized selector sent to instance 0xd5cce0'

nick is a property of the Object Person that is displayed in the cell, but I never use it on the segmented control

I load the segmented controll this way at viewWillAppear:

///// SELECTOR ALL - FAVS //////
NSArray *b=[[NSArray alloc] initWithObjects:@"All", @"Favourites", nil];
UISegmentedControl *segmentedControl=[[UISegmentedControl alloc] initWithItems:b];
segmentedControl.segmentedControlStyle=UISegmented ControlStyleBar;

[segmentedControl addTarget:self action:@selector(favs forControlEvents:UIControlEventValueChanged];
self.navigationItem.titleView=segmentedControl;
[segmentedControl release];


It seems to me the error has nothing to do with the segmented control, so I don't understand the error message
fede is offline   Reply With Quote
Old 10-16-2009, 05:02 PM   #8 (permalink)
Humbled Student
 
Dutch's Avatar
 
Join Date: Apr 2009
Location: Long Island, NY
Age: 32
Posts: 883
Send a message via AIM to Dutch
Default

It is possible your array is at some point having a segementedview added to it (obviously on accident)?
Dutch is offline   Reply With Quote
Old 10-16-2009, 05:22 PM   #9 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 26
Default

Quote:
Originally Posted by Dutch View Post
It is possible your array is at some point having a segementedview added to it (obviously on accident)?

I'll have to check on that, if it does it's definitely by accident.

However this gets stranger every time, I almost didn't make any changes and now I get this message:

Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[NSCFDictionary nick]: unrecognized selector sent to instance

I donīt use an NSCFDictionary on any part of the app!!
fede is offline   Reply With Quote
Old 10-16-2009, 05:28 PM   #10 (permalink)
Registered Member
 
Join Date: Sep 2009
Posts: 26
Default

If I don't remove any items from the array, the app runs fine
fede is offline   Reply With Quote
Old 10-07-2010, 03:40 PM   #11 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 2
Default

Quote:
Originally Posted by nobre84 View Post
I've ran into this some times. Its the animation. Until the first pop finishes you can't pop again or the nav bar buttons will bug on you. Change the second pop to viewDidAppear and see if it helps. This way it will pop back and pop again one animation at a time.
If you need to pop straight to the right controller you can try
Code:
int count = [self.navigationController.viewControllers count];
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-2]];
Keep in mind that

Code:
[self.navigationControllers.viewControllers count]
will return a number that is one more than the index for the current view. If you're popping multiple controllers, you will want to subtract one plus the number of controllers your moving back.

Another way, which might be more inelegant (but it works) is to assign a pointer to the navigation controller, then call popViewController:animated twice:

For example:
Code:
UINavigationController *navController = self.navigationController;

[navController popViewControllerAnimated:NO];
[navController popViewControllerAnimated:YES];
atomCoder is offline   Reply With Quote
Old 12-07-2010, 05:43 AM   #12 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 28
Default use of uinavigation view in second page?

Can any one tell me how to use navigation view from second page.Am trying this from last one month.

http://www.iphonesdkarticles.com/200...ting-data.html

From the second view I have to start this whole application which is in this link.
ie., in first page i need only a button and from the next page this application which is in the link must start.can any one help me


Thank u
rafiq is offline   Reply With Quote
Old 12-07-2010, 06:02 AM   #13 (permalink)
Registered Member
 
Join Date: Oct 2010
Posts: 28
Default how to use uinavigation view from second page in ipad?

Can any one tell me how to use navigation view from second page.Am trying this from last one month.

SQLite Tutorial ? Updating data

From the second view I have to start this whole application which is in this link.
ie., in first page i need only a button and from the next page this application which is in the link must start.can any one help me

smrafiqsmd@gmail.com

Thank u
rafiq is offline   Reply With Quote
Old 05-26-2011, 11:09 AM   #14 (permalink)
Registered Member
 
Join Date: Dec 2010
Location: VA
Posts: 50
Default

nobre84's is the correct answer but it should read - 3 since it's an array of viewcontrollers starting at 0, and count starts at 1

int count = [self.navigationController.viewControllers count];

[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:count-3] animated:YES];
zambono is offline   Reply With Quote
Reply

Bookmarks

Tags
navigation, pop, view

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 241
15 members and 226 guests
ADY, AragornSG, CKAmike, Dani77, Dattee, Duncan C, HDshot, HemiMG, Promo Dispenser, Punkjumper, Rudy, sacha1996, sneaky, spiderguy84, theone8one
Most users ever online was 1,187, 10-11-2011 at 08:09 AM.
» Stats
Members: 158,885
Threads: 89,231
Posts: 380,768
Top Poster: BrianSlick (7,129)
Welcome to our newest member, bookesp
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 03:18 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0