UIImagePickerController and UITextfield keyboard problems.

I am using a UINavigationController... from within one of my UIViewController, I present a UIIMagePickerController... when I press cancel... and return to my UIViewController, and press on a UITextfield... the keyboard no longer appears...


The issue seems to carry to all the UIViewControllers within my navcontroller... If I don't present the UIImagePickerController, I have no issues... seems like presenting UIImagePickerController is causing some issues as to when the keyboard renders.


When I have the cursor on my textfield (and the keyboard is not showing)... if I present the UiImagepickerController at this point... the keyboard appears for an instant before being covered by the image picker.


Does anyone know of this problem and how to solve it? Would appreciate any help. Thanks.

Posted on Mar 4, 2013 1:24 AM

Reply
3 replies

Mar 4, 2013 7:49 AM in response to RobertCus

Thanks RobertCus. Your post helped me.


The problem seems to be related to presentViewController... seems like the viewcontroller from which imagepickercontroller is presented develops textfield issues.


To counteract this I added an extra ViewController property to my current viewcontroller class (call it test). , I instantiated test in my viewdidload method.


[code]

- (void)viewDidLoad

{

[superviewDidLoad];


self.test = [[UIViewControlleralloc] init];




// [self takePhoto];


// Do any additional setup after loading the view.

}


[/code]


Then I added test.view to my current view controller's view (self.view addSubview:test.view;).


then I presented uiimagepickercontroller from test.



[code]

- (IBAction)takePhoto

{



[self.view addSubview:self.test.view];


UIImagePickerController *imagePickerController = [[UIImagePickerControlleralloc] init];

imagePickerController.sourceType = UIImagePickerControllerSourceTypeCamera;

imagePickerController.editing = NO;

imagePickerController.delegate = (id)self;



[self.test
presentViewController:imagePickerController animated:YEScompletion:nil];


}


[/code]



After dismissing uiimagepickerController... I remove test.view from superview... and I return to my original viewcontroller... and it no longer has textfield keyboard problems.


[code]


-(void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {




[picker dismissViewControllerAnimated:NOcompletion:nil];


[self.test.viewremoveFromSuperview];

}

[/code]

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

UIImagePickerController and UITextfield keyboard problems.

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.