【发布时间】:2013-07-04 20:33:19
【问题描述】:
我正在创建一个 iphone 应用程序,其中 2 个 URL 从 xml 文件传递并通过要加载到 UIImageView 中的 segue 从 UITableView 发送到详细视图。 这是我的 prepareForSegue 方法:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"detail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSMutableString *imgURL1 = [feeds[indexPath.row] objectForKey: @"imageURL1"];
[[segue destinationViewController] setImg1:imgURL1];
//img1 is declared in the detailviewcontroller class
}
}
这是我在 detailViewController 中的 viewDidLoad:
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL * imageURL1 = [NSURL URLWithString:self.img1];
NSData * imageData1 = [NSData dataWithContentsOfURL:imageURL1];
UIImage * imag1e = [UIImage imageWithData:imageData1];
appImage1.image = imag1e;
//appImage1 is also declared in the detailViewController class
}
现在的问题是,当我运行应用程序时,appImage1 中没有显示任何内容,也没有报告错误或错误。 感谢您的帮助
【问题讨论】:
-
appImage1是从情节提要中设置的吗?真的设置了吗?此外,在主线程上使用dataWithContentsOfURL也不是一个好主意。 -
是的,它是从情节提要中设置的
-
然后您进行了调试以检查
feeds是否确实包含您认为的内容以及您认为的内容?
标签: objective-c xcode uiimageview nsxmlparser segue