In the app开发者_Python百科 I am trying to build, I am trying to use the UIImageController but am running into a bit of a problem. I am not doing this in the ViewController class... Here's the code:
(IBAction) uploadBtn {
ipc = [[UIImagePickerController alloc] init];
ipc.delegate = self;
ipc.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentModalViewController:ipc animated:YES];'
Its giving me a warning with the last line, saying:
Method'- presentModalViewController:animated' not found
I am sure that if I used the ViewController class this would work but is there anything I can do/import that will let me do this in just a UIView class?
Again the app builds, but when I try to click the button it crashes
Thanks in advance!
You're crashing because only UIViewController
has that method. You can only present one view controller off of another one.
Have a look at get UIView's viewcontroller (iphone). I think you should rethink your design if you need to access view controller from a UIView.
You could present it from the view's parent view controller:
[[ipc parentViewController] presentModalViewController:yourController animated:yourBool];
精彩评论