菜鸟教程小白 发表于 2022-12-12 22:46:49

ios - Xcode 8 UIImagePickerController 卡住


                                            <p><p>我刚遇到这个问题。我可以像往常一样调用 UIImagePickerController,但是当我选择一个图像(拍摄照片或照片库)时,“使用照片”按钮和“重拍”按钮不起作用,并且 UI 只是卡住。</p>

<p>我做了一些调试,发现代码不会进入委托(delegate)方法。</p>

<p>我没有更改任何关于 UIImagePickerController 的代码。之前一切正常。所以我想知道为什么会发生这种情况以及如何修复这个错误? </p>

<p>非常感谢!</p>

<p>代码如下:</p>

<pre><code> UIImagePickerController * imgPicker = [ init];

;
;
[self.navigationController presentViewController:imgPicker animated:YES completion:^{

            }];

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(nullable NSDictionary&lt;NSString *,id&gt; *)editingInfo {

    [self dismissViewControllerAnimated:YES completion:^{
    }];
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我知道了。这是由于使用了错误的委托(delegate)方法造成的。我使用的委托(delegate)方法已<strong>已弃用</strong>。</p>

<p>我们应该使用这个</p>

<p><code>- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info;
</code></p>

<p>并且图片信息在info字典中,可以通过这种方式获取图片</p>

<p><code>UIImage *image = ;
</code></p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - Xcode 8 UIImagePickerController 卡住,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/40342718/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/40342718/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - Xcode 8 UIImagePickerController 卡住