ios - UIImagePickerController 用相机源耗尽内存
<p><p>我在使用 <code>UIImagePickerController</code> 并将图像保存在磁盘上时遇到了很大的性能问题。我无法弄清楚我做错了什么。这是我的代码:</p>
<pre><code>- (void)imagePickerController:(UIImagePickerController *)pick
didFinishPickingMediaWithInfo:(NSDictionary *)info {
UIImage *image = ;
NSData *imageData = ;
iPixAppDelegate *delegate = (iPixAppDelegate *)[ delegate];
;
}
</code></pre>
<p><code>addPicture</code> 方法创建一个以这种方式初始化的新图片对象:</p>
<pre><code>- (Picture*) initPicture:(NSData*)dat inFolder:(NSString*)pat {
self.data = dat;
NSDate *d = ;
NSDateFormatter *formatter = [ init];
;
self.name = [ stringByAppendingString:@".png"]; //The name by default of a picture is the date it has been taken
;
self.path = ;
if(!){
;
}
return self;
}
</code></pre>
<p><code>UIImagePickerController</code>相当快,但是当我将图片保存在磁盘上时,程序变得很慢。</p>
<p>知道我做错了什么吗?</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>我遇到了类似的问题。我绕过它的方法是在单独的线程中处理来自选取器的图像。我的问题是处理我的应用程序/UI 的主线程在尝试关闭选择器并处理图像时崩溃了:</p>
<pre><code>- (void)imagePickerController:(UIImagePickerController *)picker
didFinishPickingImage:(UIImage *)image
editingInfo:(NSDictionary *)editingInfo
{
[ dismissModalViewControllerAnimated:YES];
NSLog(@"picker did finish");
;
}
</code></pre></p>
<p style="font-size: 20px;">关于ios - UIImagePickerController 用相机源耗尽内存,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/2071947/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/2071947/
</a>
</p>
页:
[1]