【问题标题】:Issue With selecting multiple images选择多个图像的问题
【发布时间】:2012-12-28 18:39:15
【问题描述】:

【问题讨论】:

    标签: iphone ios camera uiimagepickercontroller freeze


    【解决方案1】:

    我假设单击“完成”按钮会调用取消选择器;在这种情况下你可以试试你是否尝试实现委托方法:

     - (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker {
          [self dismissViewControllerAnimated:YES completion:^(void) {
               NSLog(@"Cancelled pick");
          };
     }
    

    另外,您似乎正在调用release——您不使用 ARC 的任何原因?

    如果我不得不猜测,我会说也许警报解除实际上是在调用类似的东西

     [imagePicker.delegate imagePickerControllerDidCancel:imagePicker];
    

    但它已经发布,所以您会看到这个“锁定”问题。也许在调试器中单步执行并确保这些对象仍然存在。

    编辑:

    虽然它不能解决您的原始问题,但您可以在启动图像选择器之前检查可用空间,可能使用类似 this so post 的建议:

    - (uint64_t)freeDiskspace
     {
         uint64_t totalSpace = 0;
         uint64_t totalFreeSpace = 0;
    
         __autoreleasing NSError *error = nil;  
         NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);  
         NSDictionary *dictionary = [[NSFileManager defaultManager] attributesOfFileSystemForPath:[paths lastObject] error: &error];  
    
         if (dictionary) {  
             NSNumber *fileSystemSizeInBytes = [dictionary objectForKey: NSFileSystemSize];  
             NSNumber *freeFileSystemSizeInBytes = [dictionary objectForKey:NSFileSystemFreeSize];
             totalSpace = [fileSystemSizeInBytes unsignedLongLongValue];
             totalFreeSpace = [freeFileSystemSizeInBytes unsignedLongLongValue];
             NSLog(@"Memory Capacity of %llu MiB with %llu MiB Free memory available.", ((totalSpace/1024ll)/1024ll), ((totalFreeSpace/1024ll)/1024ll));
         } else {  
             NSLog(@"Error Obtaining System Memory Info: Domain = %@, Code = %d", [error domain], [error code]);  
         }    
    
         return totalFreeSpace;
     }
    

    【讨论】:

    • 我已经实现了该委托方法。单击完成按钮不会调用该委托方法。我一直在开发的旧应用程序从未真正切换到 ARC
    • 单步执行是否显示任何正在访问的 nil 对象?
    • 我不认为这是一个内存管理问题,我没有看到任何 nil 对象被访问。
    • 我实际上只是在研究计算可用磁盘空间。谢谢您的帮助
    • 当然。尽管我找不到任何详细说明系统如何处理这种情况的文档,但我仍然觉得很奇怪。你会认为他们会在某处记录它。那好吧。 :-)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-01
    • 2015-10-26
    • 1970-01-01
    • 2012-10-17
    • 2016-08-24
    • 1970-01-01
    相关资源
    最近更新 更多