[英]how do i return an NSString or NSUrl from my didFinishPickingMediaWithInfo?
美好的一天,我正在嘗試在我的selectFile函數中實現UIImagePickerController。 (在appcoda中遵循了本教程),但是下面的代碼現在根據我想要的內容進行了一些調整
@implementation FileBrowser
-(void)selectFile{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = NO;
picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
[self presentViewController:picker animated:YES completion:NULL];
}
#pragma mark - Image Picker Controller delegate methods
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
NSURL *refURL = [info valueForKey:UIImagePickerControllerReferenceURL];
NSString *myURL = [refURL absoluteString]; //not in tutorial, I'm trying to grab the url/path of the image here, with an intention of returning it to "callFileBrowser"
[picker dismissViewControllerAnimated:YES completion:NULL];
}
@end
根據我的理解,當用戶選擇圖像時會調用我的imagePickerController函數。 我的問題是我該如何返回(或獲取)URL? 我在同一個文件上(但在@implemetation之外)有一個C函數,該函數調用我的selectFile並應返回用戶選擇的URL /路徑。
char* callFileBrowser(){
[fileBrowser selectFile];
//return myURL here;
}
我希望我能夠正確地解釋一切。 任何建議將不勝感激。 謝謝。
我認為當前的設計不可能。 調用callFileBrowser()來拾取圖像,然后立即需要它返回一個值。 我們不知道用戶將在何時完成選擇,建議您在URL准備好通知需要它的其他對象時在didFinishPickingMediaWithInfo中發布通知。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.