-1
我得到一個黑色的圖像選擇器預覽。如果我刪除應用程序然後再次運行,這不會發生。所以第一次安裝到我的設備後,它運行的應用程序運行。但是,如果我在此之後調出圖像選取器控制器並捕獲圖像,則預覽是黑色的。我已閱讀所有提到後臺線程的答案,但我沒有運行任何後臺線程。林不知道是什麼造成這一點。它在第一時間完美運作,但在此之後它永遠不會起作用。黑色的UIImagePicker預覽ios7
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:animated];
//Image Picker settings
self.imagePicker = [[UIImagePickerController alloc] init];
self.imagePicker.delegate = self;
self.imagePicker.allowsEditing = NO;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
self.imagePicker.sourceType = UIImagePickerControllerSourceTypeCamera;
} else {
self.imagePicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
}
self.imagePicker.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType:self.imagePicker.sourceType];
[self presentViewController:self.imagePicker animated:NO completion:nil];
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
if ([mediaType isEqualToString:(NSString *)kUTTypeImage]) {
//dismiss view controller
[self dismissViewControllerAnimated:YES completion:nil];
}
}
沒有修復它。將更新我的問題,雖然 – Stonep123
根據您的編輯,你沒有調用[超級viewWillAppear:動畫],我的答案說做viewDidAppear:,而不是viewWillAppear:,因爲在viewWillAppear :,它仍然沒有到點你應該嘗試從中展示任何東西。 – Gavin
它需要在viewWill中,如果我把它放在viewDid中,我的視圖在圖像選取器出現之前第二秒可見。 – Stonep123