on iOS 4 i am using the following line of code to get the PhotoLibrary and its working perfect and the view can be dismissed with the cancel button appearing on top right side:
[self presentModalViewController:imgPicker animated:YES];
However, on iOS 5 the following line is getting the PhotoLibrary but the "Cancel Button" is Disable, i.e. the view cannot be dismissed with cancel button.
[self presentViewController:imgPicker animated:YES completion:nil];
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
[imagePicker setDelegate:self];
[self presentModalViewController:imagePicker animated:TRUE];
This works fine for me, in iOS 5, too.
You are not passing a view controller, but a view controller class. Try using your old imgPicker rather than the UIImagePickerController.
Also, there is no such thing as Nil in objective C. It should be nil.
Related
I am doing a partial page curl in this way:
- (IBAction)settings:(id)sender {
Settings *go = [[[Settings alloc] initWithNibName:#"Settings" bundle:nil] autorelease];
go.modalTransitionStyle = UIModalTransitionStylePartialCurl;
[self presentModalViewController:go animated:YES];
}
How do I uncurl this animation?
-(IBAction)backClicked{
[self dismissModalViewControllerAnimated:YES];
}
Just dismiss the modal view controller as you always do. iOS will take care of the transition as you have already specified the modalTransitionStyle.
[self dismissModalViewControllerAnimated:YES];
Also you can try to tap on left top corner with part of curl page to automatically dismiss view controller.
Information for > ios 6.0:
dismissModalViewControllerAnimated is deprecated now.
The new method it´s without "modal", looks like that:
[self dismissViewControllerAnimated:YES completion:nil];
I am new to Iphone development. I am working on an application which involves two views. I have a camera button in view one which opens up the default Iphone camera. This is achieved by having this code in the IBAction for camera button in ViewOneController:
UIImagePickerController *picker =
[[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[self presentModalViewController:picker animated:YES];
[picker release];
The view controller for the first view is also the UIImagePickerControllerDelegate for the camera. When the picture is clicked and the camera view returns to the function imagePickerController:didFinishPickingWithMediaInfo where I do this:
(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
[self presentModalViewController:ViewTwoViewController animated:YES];
}
So basically all I am trying to achieve is from viewone click "take picture" ---> Open camera --> after camera is done jump to view two. Quite simmilar to what it is in the flickr app. However after I take the picture from camera my app returns to view one and view two is not shown. What am I missing here?
Also from a conceptual perspective I guess IOS keeps a stack of views for any app. When presentModalViewController is called the view is shown and it is added to the stack and when dismissModalViewController is called the view is removed from the stack and the parent view is show. Is that right?
Thanks.
You probably need to put the call to [self presentModalViewController:ViewTwoViewController animated:YES] in viewWillAppear which will be called after the picker view has been removed.
You probably also need to surround the call with some check to only present viewTwo when applicable.
I want to present a modalViewController(do some picture drawing) right after dismiss the imagePickerController(exactly after finish image picking). I've tried to set up a IBAction with a bar button and it works fine when I tap it. But what I want is present the modalViewController as soon as I finish the image picking
Here is my code:
-(void)imagePickerController:(UIImagePicerController*)picker didFinishPickingMediaWithInfo:(NSDictionary*)info{
[self dismissModalViewControllerAnimated:YES];
//dismiss the imagePickerController
drawViewController *drawView = [[drawViewController alloc] init];
[self presentModalViewController:drawView animated:YES];
}
Thanks!
The dismiss and presentModal can't both animate in the same method. The presentModal will seem to do nothing. For the dismiss, try setting the animated to NO.
After dissmissing the imagePickerController the viewDidAppear is called. You can there call the drawViewcontroller.
-(void)viewDidAppear:(BOOL)animated{
drawViewController *drawView = [[drawViewController alloc] init];
[self presentModalViewController:drawView animated:YES];
}
MFMailComposeViewController displaying only bar at the top of the screen with the cancel and send buttons. Code for landscape:
MFMailComposeViewController *controller = [[MFMailComposeViewController alloc] init];
controller.mailComposeDelegate = self;
[controller setSubject:#"In app email..."];
[controller setMessageBody:#"...Hi, all...." isHTML:NO];
//[self presentModalViewController:controller animated:YES];
controller.view.frame = CGRectMake(0,0,480,320);
[self.view addSubview:controller.view];
[controller release];
What is problem?
i've ever seen this problem before, as far as i know, you shouldn't replace the presentModalViewController method with addsubview.
I was getting this behavior, as well as the modal view coming in from the side and the modal view was stopping a quarter of the way through presenting.
In my app I had many view controllers stacked with addSubview:. I don't know why but it worked to present the modal view from the bottom view controller. I did something like this:
[((FirstViewController*)[UIApplication sharedApplication].delegate).firstViewControllerInstance sendEmailwithInfo];
Hope that helps! And maybe someone can give some insite as to why it was happening.
I am using TabBarController in my application. In one of the view of the tabbar I am using a UIImagePickerController to pick an image.
When I add the picker as follows
UIImagePickerController *imagePicker = [[UIImagePickerController alloc] init];
imagePicker.delegate = self;
imagePicker.editing = YES;
[self presentModalViewController:imagePicker animated:YES];
[imagePicker release];
It adds the picker, But at the time of choosing the photo, The bottom bar having the buttons "choose" and "cancel" gets hide under my tabbar. How to resolve this .
The problem is that you are using self as the navigation controller that shows the modal screen. Therefore the tab bar navigation controller does not know that a modal screen should fill the whole screen. Since the UIImagePickerController can not adjust itself to a smaller size you have to use the tab bar navigation controller to open present the modal view.
I use the following code to show a UIImagePickerController from a navigation controller that is shown inside a tabbar:
[self.navigationController presentModalViewController:picker animated:YES];
using self.navigationController instead of self as the object that presents the UIImagePickerController did the trick for me.
This works for me:
picker.delegate = currentClassViewController;
[tabBarController presentModalViewController:picker animated:YES];
Have your picker-caller class own or have access to your UITabController variable and presentModalViewController against your tabBarController.
I haven't seen this problem - I have an app that uses a UITabBar and a UIImagePickerController together, and the tab bar does not obscure the image picker.
Inside my view controller, which is one of the UITabBar's view controllers, I'm creating the image picker as such:
self.imagePicker = [[[UIImagePickerController alloc] init] autorelease];
imagePicker.allowsImageEditing = NO;
imagePicker.delegate = self;
[self presentModalViewController:imagePicker animated:YES];
Seems very similar to your code, except that I'm setting the image picker as a retained property. Is your tab bar set up correctly? Is the view controller contained within the myTabBar.viewControllers array?