Memory leak on popToViewController - iphone

Hi
I am using following method to go back to one of the previous view. This is working. But I got two issues with this.
This line gives a memory leak when I use Instrument.
After popup to particular view, when I press left navigation button (back button) just only this button will disappear and view will remain.
Can anyone please let me know how to overcome these issues?
[self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIndex:1] animated:YES];
Thank you

try [self.navigationController popViewControllerAnimated:YES]; if you just with to remove current view from the view hierarchy,

If you, as you describe, just wants to pop just the active viewController, you can use
- (UIViewController *)popViewControllerAnimated:(BOOL)animated
documentation here.
If this still give problems, there is something wrong with your viewController hierarchy.

Hi agree with the above answers
try these methods carefully
[self.navigationController popToRootViewControllerAnimated:YES];
[self.navigationController popToViewController:(UIViewController*)
animated:(BOOL)];
Working with iOS5.
[self.navigationController popViewControllerAnimated:(BOOL)];

Related

how to use pushViewController in ReaderSample of ZBarReader project

I am working on the ReaderSample of ZBarReader project,instead of use
[self presentModalViewController: controller animated: YES];
I am trying to use
[self.navigationController pushViewController:controller animated:YES];
and when I run the application, there is nothing happens at all
I am wondering why I cant use pushViewController
Please advice me on this issue.
Thanks
EDIT:
The underlying reason is that apple does not allow stacking of navigation bars and UIImagePickerController has one of its own so than you will have two and will be confused..
The ZBarReader uses UIImagePickerController as its base class (not actually but internally somewhere ) and as you might be knowing you can't push a UIImagePickerController object on a navigation controller... that's why you have to use presentModalViewController
(Modal view controllers are used to tell the user that something important is happening apart from the normal app usage and clicking a picture is a part of that.. . its in the HIG)...
hoping this helps..

Kill View and back to rootViewController

I am new to IOS, sorry in advance if I ask a stupid question.
I use UITabBarController and navigationController to control view.
At my last view, I would like to have a button when the button is pressed, view will return to rootViewController which I set by MainWindow.xib file and kill any process which run in app background.
this is my code in the last view before I want to back to rootViewController:
-(IBAction)doneButtonPressed:(id)sender{
JourneyIndexViewController *journeyIndexVC = [[JourneyIndexViewController alloc] initWithNibName:#"JourneyIndexViewController" bundle:nil];
[journeyIndexVC setDistanceLabelValue:self.distanceLabelValue];
[self.navigationController pushViewController:journeyIndexVC animated:YES];
[journeyIndexVC release];
[self dismissModalViewControllerAnimated:YES];
}
JourneyIndexViewController is the rootViewController that I set in MainWindow.xib.
Thank you very much for your advance support.
try
[self.navigationController popToRootViewControllerAnimated:YES];
You should take a look at this: UINavigationController Class Reference for better understanding
I am making a few assumptions here, but if JourneyIndexRootViewController is your rootViewController and is created in IB (in a nib), you do not need to re-crete it when pushing the button. It sounds like you simply need to remove the UINavigationController that you added on top of the rootViewController.
Try this. This should pop you back to the Previous View Controller.
[self.navigationController popViewControllerAnimated:NO];
Hope this helps

When trying to view table view after viewing another, app crashes

i have a tough one for you today. I have two tableViews in my app the first is on the first page. There are two other pages the user drills down to get to the second table view. After i leave the first table view, i can press the back buttons to get back perfectly until i reach the second table view. As soon as i drill down to the second table view and then try to return to the first via pressing the back buttons. As soon as i get to the last back button to return to the first table view, the app crashes. The code for the back buttons is simply:
- (IBAction)goBack:(id)sender {
[self dismissModalViewControllerAnimated:YES];
}
Any Help Would be greatly appreciated!! Thanks everyone!! :D
Whenever I create a modal view controller from a XIB, the automatic #property generator duplicates things in the Dealloc method, thus throwing an EXC_BAD_ACCESS when the view is dismissed. Make sure you aren't releasing something twice.
Sounds like your are releasing something too early. Open you app in instruments (command + i) and run a zombie test.
As soon as you see zombie has been messaged expand the right panel and have a look at the user code (your code) blocks. Indicated by the back person icon.
Double click that and it will indicate what it was trying to access that had already been released.
Are your tableviews being displayed in a modal window? If not, why are you calling [self dismissModalViewControllerAnimated:YES]? Shouldn't you be calling [[self navigationController] popViewControllerAnimated:YES]?
If you're using a UINavigationController, the back button functionality should be provided automatically.
if you are using [[self navigationController] popViewControllerAnimated:YES] to
then for back you write as mentioned below:
(IBAction)goBack:(id)sender {
// Tell the controller to go back
[self.navigationController popViewControllerAnimated:YES];
}
if you are using [self presentmodalviewcontroller: animated:]
then only [self dismissModalViewControllerAnimated:YES] will work
you try this [[self navigationController] popViewControllerAnimated:YES]

Why does animating a modal view controller onscreen cause a crash here?

This piece of code works fine. However, if I change the animated parameter to YES it crashes.
AccountViewController *accViewController = [[AccountViewController alloc] initWithNibName:#"Account" bundle:nil];
[self.navigationController pushViewController:accViewController animated:NO];
[accViewController release];
What could be wrong?
Are you doing this while any other animation is going on? I've seen crashes here in that type of situation (for example, while one view is being dismissed, pushing or presenting another will crash.)
Try dropping the release call. Although I would assume that push should retain, I can't recall for sure and i am not sure when it retains.

how to move the control from one uiview to another uiview in iphone?

I created a uiview(with two buttons) covers all the screen whenever i click on any one of button i want to transfer my control on previous screen what can i do in iphone?
code for navigating from one view to another is as belove :
DetailViewController *detailViewController;
[self.navigationController pushViewController:detailsViewController animated:YES];
and for going back :
[self.navigationController popViewControllerAnimated:YES];
leave comment if have any trouble...
and click on correct sign if its correct...and votes up the answer to help another guys to see it.
if you are using NavigationController than for going back to previous view...
[self.navigationController popViewControllerAnimated:YES];
Otherwise
[self dismissModalViewControllerAnimated:YES];