我正在尝试将 URL 从 传输UITableViewController
到UIViewController
,但由于某种原因,图像没有UIImageView
从提交的 URL 中显示。这是我的代码:
表视图.m
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSString *url = @"http://www.macdigger.ru/wp-content/uploads/2013/02/Apple-Nokia-Samsung-1.jpg";
ImageViewController *imageView = [[ImageViewController alloc] init];
[self.navigationController pushViewController:[self.storyboard instantiateViewControllerWithIdentifier:@"imageViewController"] animated:YES];
[imageView setDetailItem:url];
}
ImageViewController.m
@interface ImageViewController ()
- (void)configureView;
@end
@implementation ImageViewController
- (void)setDetailItem:(id)newUrl
{
NSLog(@"%@", newUrl);
self.urlOfImage = newUrl;
[self configureView];
}
- (void)configureView
{
NSURL *url = [NSURL URLWithString:_urlOfImage];
NSLog(@"%@",url); //There URL is normally displayed in the log
NSData *data = [NSData dataWithContentsOfURL:url];
UIImage *image = [UIImage imageWithData:data];
_imageView.image = image;//And then the picture does not want to output
}
在日志中显示传递的 URL(粗体)。事实证明,URL 本身被传递,但是UIImageView
,不显示来自该 URL 的图像。
PPS数据以以下形式显示在日志中"<ffd8ffe1 00184578 69660000 49492a00 08000000 00000000 00000000 ffec0011 4475636b 79000100 04000000 460000ff e1031b68 7474703a 2f2f6e73 2e61646f 62652e63 6f6d2f78 61702f31 2e302f00 3c3f7870 61636b65 74206265 67696e3d 22efbbbf 22206964...>"