Photo Library view stays on screen after choosing an image with UIImagePickerController

本秂侑毒 提交于 2019-12-05 12:13:51

You need to access the viewController of the picker not the picker itself. Try this line instead.

[[picker parentViewController] dismissModalViewControllerAnimated:YES];

You can just call

[self dismissModalViewControllerAnimated:YES];

to dismiss any modal view controller on top of the current view.

This makes sense since you present the view controller by calling:

[self presentModalViewController:picker animated:YES];

Just an update to the answers to this

 [self dismissModalViewControllerAnimated:YES];

has been deprecated in iOS 6.0 so you now need to use.

 [self dismissViewControllerAnimated:YES completion:nil];

Not a huge change but for anyone that looks at this question and they are using iOS 6.0 they will need an updated answer.

 [self presentModalViewController:filePicker animated:YES];

has also been deprecated in favor of

 [self presentViewController:filePicker animated:YES completion:nil];
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!