我有我的程序中的代碼,但它似乎崩潰的程序,我不知道爲什麼。如何從iOS照片庫加載圖像到UIWebView?
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
//Get Image URL from Library
NSURL *urlPath = [info valueForKey:UIImagePickerControllerMediaURL];
NSString *urlString = [urlPath absoluteString];
NSLog(urlString);
NSURL *root = [[NSBundle mainBundle] bundleURL];
NSString *html;
html = @"<img src='";
html = [html stringByAppendingString:urlString];
html = [html stringByAppendingString:@"' />"];
[MemeCanvas loadHTMLString:html baseURL:root];
[picker dismissViewControllerAnimated:YES completion:^{}];
}
它似乎是由於我將資產庫地址(urlString)追加到html字符串的部分引起的。我不知道爲什麼這會產生問題。
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[__NSCFConstantString stringByAppendingString:]: nil argument'
任何幫助表示讚賞。
在此先感謝。
它打印什麼'NSLog(urlString);'? – Maulik
原因很簡單,你追加了零字符串。 –
urlString可能爲零 – Mathijs