0
我試圖在彈出窗口中顯示UiImagePicker,因爲它應該是爲iPad完成的。但是,當選擇圖片和imagePickerController:didFinishPickingMediaWithInfo:被觸發時,我得到以下日誌:UIImagePickerController在iPad模擬器上崩潰
命名服務「com.apple.PersistentURLTranslator.Gatekeeper找不到。資產已關閉或配置錯誤。事情不會像你期望的那樣工作。
這是我的代碼:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
imagePickerController = [[UIImagePickerController alloc] init];
imagePickerController.allowsEditing = NO;
imagePickerController.delegate = self;
imagePickerController.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
// Check device
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[self dismissModalViewControllerAnimated:YES];
}
else {
[popoverController dismissPopoverAnimated:YES];
}
// More code here to save the selected image
}
- (IBAction)showImagePicker:(id)sender
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
[self presentModalViewController:imagePickerController animated:YES];
}
else {
popoverController=[[UIPopoverController alloc]
initWithContentViewController:imagePickerController];
[popoverController presentPopoverFromRect:((UIButton *)sender).frame
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionAny
animated:YES];
}
我該怎麼辦丟失或做錯了什麼?謝謝!
謝謝,它似乎是這樣的...我在iPad模擬器上得到這樣的日誌消息,如果我第一次運行應用程序在iPhone模擬器打開該項目後,反之亦然。我試着在真實的設備上運行,它的工作原理。 – AppsDev