2013-01-14 82 views

回答

2

我假設點擊「完成」按鈕會調用取消選擇器;在這種情況下,你可以試試你嘗試實現的委託方法:

- (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; 
} 
+0

我已經實現了該委託方法。點擊完成按鈕不會調用該委託方法。我一直在努力的舊應用程序從未真正切換到ARC – user1861763

+0

是否逐步顯示正在訪問的任何零對象? –

+0

我不認爲它是一個內存管理問題,我沒有看到任何無法訪問的對象。 – user1861763