我做了一個測試應用程序,使用相機按鈕拍照。我正在模擬器上測試,所以我無法拍攝快照。但是我創建了一個IBAction方法,在調用時允許用戶從照片庫中選擇一張照片。 這是該方法: -NSLog不執行
- (IBAction)takePicture:(id)sender {
NSLog(@"Camera button tapped");
UIImagePickerController *imagePicker= [[UIImagePickerController alloc] init];
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
NSLog(@"Yes. The Camera is available");
[imagePicker setSourceType:UIImagePickerControllerSourceTypeCamera];
}
else{
NSLog(@"The Camera isn't available. Try thru the Photo Library");
[imagePicker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
}
imagePicker.allowsEditing=YES;
[imagePicker setDelegate:self];
NSLog(@"Presenting Modal Controller");
[self presentViewController:imagePicker animated:YES completion:NULL];
}
在上述情況下,當方法被調用(即當我點按相機欄按鈕項),控制檯不記錄照相機按鈕抽頭消息以及作爲呈現模態控制器 message.All其他適當的NSLog消息正在被記錄,因爲它們應該是。 我不明白爲什麼運行時不執行這些NSLog行。 在有一個類似的問題 - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info我面對。 這裏的實施 -
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info{
NSLog(@"imagePicker called");
NSString *oldKey= _item.imageKey;
if (oldKey) {
NSLog(@"Deleting image having key- %@",oldKey);
[[BNRImageStore sharedStore] deleteImageForKey:oldKey];
}
UIImage *image= [info objectForKey:UIImagePickerControllerEditedImage];
CFUUIDRef newUniqueID= CFUUIDCreate(kCFAllocatorDefault);
CFStringRef newUniqueIDString= CFUUIDCreateString(kCFAllocatorDefault, newUniqueID);
//Use that uniqueID to set our item's imageKey
NSString *key= (__bridge NSString *)newUniqueIDString;
_item.imageKey=key;
//Store image in the BNRImageStore with this key
NSLog(@"putting %@ in dictionary table",_item.imageKey);
[[BNRImageStore sharedStore] setImage:image forKey:_item.imageKey];
//Releasing Core-Foundation objects
CFRelease(newUniqueIDString);
CFRelease(newUniqueID);
[imageView setImage:image];
NSLog(@"Dismissing Modal Controller");
[self dismissViewControllerAnimated:YES completion:NULL];
}
這裏。 NSLog消息-imagePicker調用並在第三個最後一行解除模式控制器沒有顯示在控制檯中。運行時不再處理這些NSLog行。
我假設有什麼問題,因爲這種行爲非常奇怪。發生了什麼?
這聽起來像是派生的數據問題。嘗試刪除您的派生數據並做一個乾淨的構建 –
究竟是一個派生數據? – rahulbsb
刪除特定文件夾的內容是否安全?它會做什麼? – rahulbsb