我有一个处理扩展的 webView。一部分是图像文件扩展名。到目前为止,我能够将它推送到一个新的视图控制器,但是图像没有传递并加载到新视图中。我想我犯了一个愚蠢的错误,只需要一点指导。
这是代码处理和推送视图控制器。
//Image file links
NSURL *imageURl = [request URL];
NSString *imageFileExtension = [imageURl pathExtension];
//Image file extensions
NSLog(@"fileExtension is: %@", imageFileExtension);
if ([imageFileExtension hasSuffix:@"png"] || [imageFileExtension hasSuffix:@"jpg"] || [imageFileExtension hasSuffix:@"jpeg"]) {
//Image manager
ImageViewController *vc = [[ImageViewController alloc] init];
[self.navigationController setNavigationBarHidden:NO];
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:1];
[self.navigationController pushViewController:vc animated:YES];
它被推送到的控制器是一个常规的视图控制器。不确定我是否应该将其设为图像视图控制器或另一个 webView 控制器,因为图像已经在 webView 中。
我意识到如果我点击它会加载的图像,因为它位于 webView 中,但是我们遇到了更大图像的问题并且无法导航回上一页。
任何帮助表示赞赏。
8/19 更新,来自 webView 的代码试图推送图像..
//Image file links
NSURL *imageURl = [request URL];
NSString *imageFileExtension = [imageURl pathExtension];
//Image file extensions
NSLog(@"fileExtension is: %@", imageFileExtension);
if ([imageFileExtension hasSuffix:@"png"] || [imageFileExtension hasSuffix:@"jpg"] || [imageFileExtension hasSuffix:@"jpeg"]) {
//Image manager
ImageViewController *vc = [[ImageViewController alloc] init];
[self.navigationController pushViewController:vc animated:YES];
[self.view addSubview:imageView];
ImageViewController 代码。
。H
@interface ImageViewController : UIViewController{
UIImageView *imageView;
}
@property (nonatomic, retain) UIImageView *imageView;
@end
.m
- (void)viewDidLoad {
[super viewDidLoad];
imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0.f, 0, self.view.frame.size.width, self.view.frame.size.height)];
[self.view addSubview:imageView];
[self.navigationController setNavigationBarHidden:NO];
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:0/255.0f green:0/255.0f blue:0/255.0f alpha:1];
self.view.backgroundColor = [UIColor colorWithRed:30/255.0 green:30/255.0 blue:30/255.0 alpha:1.0];
}
}