presentModalViewController is not working for the button event in iphone? - iphone

In my application i have used the UiViewController and able to push the other view using the PushViewController.
But, whenever i am using the presentModalViewController at that time i am not able to get whole functionality of the BackButton click event on the view which is working fine for the pushviewController.By using the debug i am able to reach at the function,but not able to execute the whole piece of code into that function.i have used below code.
[self.navigationController popViewControllerAnimated:YES];
[self.navigationController dismissModalViewControllerAnimated:YES];
But not able to get back to the push page.None of the lines effect is seen on the application.
Can any body give me any suggestion if i have done something unusual from transferring from PushviewController to presentModalViewController?
i just want the presentModalViewController in my application for some effect as horizontal or vertical.But,i am not able to see any effect of the event on that view.i am able to see the horizontal and vertical effect.
please guide me with proper resolution or any other solution which would be appreciated.
Thanks,
Mishal Shah.

I don't think the navigationController property is set inside of your ModalViewController. So saying self.navigationController wouldn't work inside of your Modal View Controller. That is, if that's even where you put it, I don't really understand from the way you formatted your question.
If you want more help post some more code/format it better/start accepting more answers to your questions.

I think accepted practice is to dismiss the modal view controller from the view control in which you presented it. Use a notification to send a message back to the presenting controller and dismiss it there.
I think that is what you were asking, the question is somewhat unclear.

Related

"Warp" to a view iPhone iOS

I am currently developing an App based on a Navigation Controller. However, when the user logs out, I'd like to go to the initial screen and destroy all of the other views that were stacked. What is the best way to do that?
EDIT:
I've tried doing what both answers suggested but I got a nil navigationViewController. So I'll add another detail that I thought was not useful before. Actually I am trying to perform this operation from a TabViewController that is embedded in a NavigationController. I apologize if that changes anything.
[self.navigationController popToRootViewControllerAnimated:YES];
Send a popToRootViewControllerAnimated message to the navigation controller

Managing navigation views on the stack

Being new to iPhone development I am really struggling with this concept. I have built an App which is not quite running the way that it should. I have a TabBar app. The secondViewController is essentially a form which I use to collect information about daily exercise. I have embedded this secondViewController into a Navigation controller so that I can push to a datePicker view and return with the date. I also push to a pickerView for exercise type and return with data. At least this is the intended process. I use the prepareForSegue to push the picker views and return to the secondViewController carrying data between them with each segue.
What I find is happening is that instead of pushing to the picker views and returning to the secondViewController my app seems to progress in a linear fashion. To be more precise it seems to push to the date picker, then push to a new 'instance' of the secondViewController, then push to pickerView, and then to another new instance of secondViewController. This means that when my users eventually touch the save button, they have to use the back button in the navBar to get back to the original secondViewController.
[Have an image to add but can't post it as I have reputation under 10 :-( ]
I have read Apple's documentation on managing the stack and hierarchy, but I just seem to have confused myself more than anything else. I have also searched for answers and tutorials, but I am either missing something or there is no clear explanation of how this is supposed to work that I can find. Can anyone tell me how to push to a pickerView and then return, or at least to return programmatically to the original secondViewController when the save button is finally touched?
To go Back in hierarchy in UINavigation Controller you can use
[self.navigationController popViewControllerAnimated:YES];

Loading an external view controller, from a button click on another view controller

Im officially getting annoyed with objective-c and xcode now. Programming in PHP and Java is so much easier haha.
Anyway I could do with some help.
I have created a tab bar application with three tab items for the iPhone, on one of the items it loads a nib named mapView, this contains a button that I want to use to load up another nib named OverlayViewController.
Ive been following this tutorial this tutorial
to create a camera overlay. I understand how it works, but I don't understand how to run the view controller from a button or direct from the tab bar. I can only get the overlay to work if I load it like in the example on application launch in the app delegate. If I try and load it from the tab bar item I just get a grey screen, looks like the blank view controller is loaded and the code hasnt been run to show the overlay.
If anyone can suggest how I would go about loading the overlay from the button click, or even direct from the tab bar item I would be really grateful.
Thanks Alex
p.s. Heres the link to the project if you wish to view the files
#AlexApps I took a look through your project and have several pieces of feedback.
I think before you get too into trying to get the OverlayViewController working you should back up a bit and give some of the Apple docs a read, especially the View Controller Programming Guide. The Apple docs are for the most part well written and should help you gain a better understanding of views and view controllers than what is evident in your code.
Another suggestion is to grab some of the freely available source code from a book such as Beginning iPhone Programming which has a good example of how to lay out a tabBarController based app. I am sure there are other good samples out there that will show you how to organize your views and view controllers to load them into the different tabs.
I think that if you follow this advice that by the time you have restructured your app by what you learn you will have less problem doing what you are trying to do.
BTW, you may want to consider using a NavigationViewController for what you are trying to do with loading the OverlayViewController with a button press but take a few hours, slow down and do some focused reading. It will make a world of difference. Then if you have more specific questions, Stack Overflow (and Google) are your friends.
One last tip, you do not need to put IBOutlet in your instance variables AND in your properties, just one or the other, and really, you don't even need the instance variables at all anymore. I usually just use properties for everything.
I have done it with storyboard and the solution is to create a segue between the tab bar view controller and the view controller you want to load, then you have to put an identifier to that segue. Finally, in the method called when the button is pressed you have to put this:
[self performSegueWithIdentifier:#"segueId" sender:sender];
I have done it right now and it works perfect!
First import uiviewcontroller class in frist page like below:
#import "page2viewcontroller.h"
on button click event code below:
page2viewcontroller *page2 =[page2viewcontroller alloc] ;
[self presentModalViewController:page2 animated:NO];
[page2 release];
after back page2viewcontroller to page1viewcontroller same as like below:
#import "page1viewcontroller.h"
on backbutton click event code below:
page1viewcontroller *page1 =[page2viewcontroller alloc] ;
[self presentModalViewController:page1 animated:NO];
[page1 release];
That's all....!

How to achieve this in my iPhone/iPad application?

How to get above thing in my application?
What is this? I don't know what we call this type of thing can any one guide me for this and the technical term of this?
Thanks in advance..
You can use one view controller to present another view controller modally on top of it.
[currentViewController presentModalViewController:viewControllerToPresentInModalWindow
animated:YES];
By default, the modal view controller will be full-screen, but you can change the size to one of two other presets.
[viewControllerToPresentInModalWindow setModalPresentationStyle:UIModalPresentationPageSheet];
[viewControllerToPresentInModalWindow setModalPresentationStyle:UIModalPresentationFormSheet];
Additionally, you can set the transition used to display the modal window on screen by using setModalTransitionStyle:.
The screenshot posted above is not using any of these presets; as the other commenters mentioned, it is a custom modal window that doesn't leverage UIKit's built-in modal functionality.

Two Views in 1 view controller

Basically, what I am trying to do is I have my TestViewController and there are 2 views under it, the first view will start with a tool bar and 2 buttons, one for imagepicker and the other one for mail sending, I am already done with that, and after pick the image from the photo library, the second view will be popped out(I want to do some image editing here) with a tool bar and 1 button back to the first view. I am doing something like [self.view addSubview:2ndview], and it works, but when I am trying to use -(IBAction)dismissDrawing:{[2ndview removeFromSuperview] }the program just shut down.
Can anyone help me? Really appreciate your help!
Look at my sample application I did last year. Basically you need a view that will act like a superview, then add views on top of it (if I remember correctly, it's been a while since I did it that way, now I just use multiple xibs).
It sounds like what you're trying to do would be better suited to a modal view.
See Human Interface Guidelines - Modal Views
Instead of adding a subview, try
[self presentModalViewController:secondView animated:YES];
Then in the dismissDrawing you can use
[self dismissModalViewControllerAnimated:YES];