how to use pushViewController in ReaderSample of ZBarReader project - iphone

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..

Related

Xcode sub navigation views

Does anyone know of any good tutorials for the following please?
Im new to Xcode and dont know where to start with this.
I have a ViewController that is the root View and has 6 navigation buttons (UIButton) on it. Depending on which button that is clicked, the user will see a sub-navigation View of that section with further button options on it.
So e.g top level will have buttons Where to Eat, What to Do...
Then clicking on Where to Eat will show Restaurants, Fast Food ....etc
I would like to do this programatically. I can do it using Storyboards and using multiple views, but it gets very messy as there are a lot of views on the screen eventually.
I have followed a tutorial HERE on how it is done for TableViewControllers, but I need something similar for buttons.
Im not sure what this function is called - have been searching for sub-navigation for the last while but nothing matches what I need to accomplish this.
Check out UIViewController's method presentViewController:animated:completion: method. It is available in iOS 5.0 and up. Let's say you have one of the button's linked to run the buttonOneActivated: method:
-(IBAction)buttonOneActivated:(id)sender
{
UISubViewController *subViewController = [[UISubViewController alloc] init];
[self presentViewController:subViewController
animated:YES
completion:NULL];
}
And in UISubViewController's implementation, let's say you have another button in order to return to the parent:
-(IBAction)returnToParent:(id)sender
{
[[self presentingViewController] dismissViewControllerAnimated:YES
completion:NULL];
}

dismissModalViewControllerAnimated crashing on iOS6

I am facing a crash on iOS 6.0. I have a view controller from which I present a navigation view controller modally and then from the navigation stack I present another view controller modally and finally to dismiss the whole modal stack I pass the following message to my first view controller from where I showed the navigation controller.
Now this works fine on iOS below 6.0. How should I handle this?
[self dismissModalViewControllerAnimated:YES];
I had this similar crash as well and one of the things helped me solve it was adding:
vc.modalPresentationStyle = UIModalPresentationCurrentContext;
maybe because dismissModalViewController is deprecated in iOS6? Try
[self dismissViewControllerAnimated:YES completion:nil];
EDIT: Lets say you add a method to appDelegate called 'makeMeNumberOne:(UIViewController *)vc':
(I know you use the 'modal' versions, they are deprecated in iOS6, switch to 'presented' variants)
. Also I assume you can find the navigationController, if this is a problem add a comment I'll further expand this, and assume you are using ARC.)
the parameter you have is a strong reference, it holds the current presented viewController, lets call it pvc
ask the navigationController for its viewControllers, and get the last one
as a debugging tool, verify that this vc has a non-nil presentedViewController property
message the last view controller above:
[lastOne dismissViewControllerAnimated:NO completion:^{
[navigationController.viewControllers = #[pvc];
}];

Memory leak on popToViewController

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)];

Help Menu iPhone

I have a design question/technical question about my iPhone app.
I have a pretty simple (read really really simple) single view application. And it does everything that I need it to do. However I find myself in need of a help view. And I really don't quite know what to do!
I have a simple helpButton() method in my main view controller, and I really just want to display a scrollview with a bunch of images that show what to do during the use of my app. However, should I make a new viewcontroller class? How do I call it from my method?
Really I was thinking of an unfortunately simple method, just putting a scrollview behind everything and hiding it. Then showing it when the IBAction is called. Horrible...
Sorry if this is elementary, I haven't needed to do anything more yet!
You can push a modalViewController. To do that just make a new viewController with the scrollview and associated data in it, then
MyViewController *myViewController = [[MyViewController alloc] init];
[self presentModalViewController:myViewController animated:YES];
Create an IBAction in your new viewController and a hooked up button to that action to dismiss the modalView (something like this:
IBAction done {
[self dismissModalViewControllerAnimated:YES];
}
A couple options:
1) Create a new UIView object, either programmatically, or even in your existing XIB file. Use the [self.view addSubview:view] method to display it.
2) Create a new UIViewController with its own XIB file. Use [self presentModalViewController:anaimated:] to display it.
Either way, you'll need to add something to the new view to dismiss it when you're done.

I would like to flip my app's splash screen - how can I mimic the flipside controller's animation?

I've finally gotten a working "alpha" version of my first app installed and (mostly) working on my iPhone 3G. So excited I came into the house and danced a little jig while my wife rolled her eyes at me. Don't care - totally stoked that I figured it out on my own (with lots of help here - thanks again, guys).
I've never really dabbled with or cared about animation; I'm more into utility-type apps. However, I've decided that I'd like to animate my app's opening image / default.png / splash screen similar to the flipside view controller animation - where the image spins from a view on the front to a different view on the back. I've found code for animating between views using the flipside animation, but how would I go about animating from a static *.png image to my navigation-based table view? I'm just not even sure where to start with this one - literally the first time I've ever even searched for anything graphics-related in the documentation.
Any help will be appreciated. As usual, thanks in advance!
You can't do anything with your Default.png, and just for form I'll point out that that HIG guidelines say that you shouldn't use it as a splash screen :-).
I would suggest that you use your initial view controller to duplicate the Default.png, and copy the flip animation code from a basic Utility app template - you probably want to use [NSObject performSelector:#selector(...) afterDelay:0] to get it to flip, called from your initial viewDidLoad:.
You can just present a modal view controller when you first launch using the flip transition instead of the default slide. Have your initial view controller loaded from your xib just display the same image you are using for your Default.png. Once you get the -viewDidLoad call in your initial view controller, push the modal view specifying the transition you want. Something like this:
- (void)showMainView;
{
MainViewController *controller = [[MainViewController alloc] init];
[controller setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal];
[self presentModalViewController:controller animated:YES];
[controller release], controller = nil;
}
As Paul suggested, you should call this using performSelector:withObject:afterDelay:
[self performSelector:#selector(showMainView) withObject:nil afterDelay:0.15];
Hope that helps.