实现在程序中显示网络图片,但图片格式是以.XXX结尾
- NSString *urlString = @“http://hiphotos.baidu.com/zhdq10/pic/item/a2a0fd24884d7149908f9dfb.jpg”;
- NSURL *url = [NSURL URLWithString:urlString];
- NSData *myData = [NSData dataWithContentsOfURL: url];
- UIImage *myImage = [UIImage imageWithData: myData];
- UIImageView *myImageView = [[UIImageView alloc] initWithImage: myImage];
- UIScrollView *myScrollView = [[UIScrollView alloc] initWithFrame: CGRectMake(0, 0, 320, 480)];
- myScrollView.contentSize = CGSizeMake(myImage.size.width, myImage.size.height);
- [self.view addSubview: myScrollView];
- [myScrollView addSubview: myImageView];
拷贝到viewDidLoad中直接可以在程序中显示图片。 之前的想法宣告失败,当连接摄像头的视频地址时,无法显示图片,本想以10Hz的频率刷新显示,以提供动态图片的设想夭折。