ios - UIImagePickerController 偶尔会死机
<p><p>我在 Unity 应用程序中使用 <code>UIImagePickerController</code>。当用户按下“完成”时,它偶尔会卡住。它最常发生在 3GS 上——大约每三次——但我也偶尔在 iPhone 5 上死机。这个错误出现在 iOS 4.3 到 7.0 中。我无法确定与卡住相关的因素。当我得到这个卡住时,我也没有收到内存警告。</p>
<p>日志中没有错误,也没有任何崩溃日志。该应用程序继续像往常一样在 <code>UIImagePickerController</code> 后面运行。控制台中有很多看似相关的消息,例如“拒绝文件写入数据/private/var/mobile/Media/PhotoData”,但它们偶尔会在出现卡住和一切正常时出现好的。</p>
<p>这是我显示选择器的方式:</p>
<pre><code>- (void)showPicker:(UIImagePickerControllerSourceType)type
{
imgPicker = [[ init] autorelease];
imgPicker.delegate = self;
imgPicker.sourceType = type;
imgPicker.allowsEditing = _pickerAllowsEditing;
// wrap and show the modal
;
}
</code></pre>
<p>这里是委托(delegate)方法:</p>
<pre><code>- (void)imagePickerController:(UIImagePickerController*)imgPicker didFinishPickingMediaWithInfo:(NSDictionary*)info
{
NSLog( @"imagePickerController didFinishPickingMediaWithInfo");
// If the freeze is present, this method isn't called
}
- (void)imagePickerController:(UIImagePickerController *)imgPicker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
NSLog( @"imagePickerController didFinishPickingImage");
// Tried to use deprecated callback. If the freeze is present, this method isn't called either.
}
</code></pre>
<p>我会认为这是 <code>UIImagePickerController</code> 中的一个错误,但没有使用 Unity 的 iOS 开发人员遇到过这个问题,我想如果这样的错误已经修复,如果它出现在 4.3 中。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>有一个解决方法:你可以在 UnityAppController.mm 中将 CFRunLoopRunInMode 静音,如下所示:</p>
<pre><code>- (void)repaintDisplayLink
{
;
{
static const CFStringRef kTrackingRunLoopMode = CFStringRef(UITrackingRunLoopMode);
if (!)
{
while (CFRunLoopRunInMode(kTrackingRunLoopMode, kInputProcessingTime, TRUE) == kCFRunLoopRunHandledSource)
;
}
}
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - UIImagePickerController 偶尔会死机,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/19591701/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/19591701/
</a>
</p>
页:
[1]