我有一個webView,它處理擴展。一部分是圖像文件擴展名。到目前爲止,我可以將它推送到一個新的視圖控制器,但圖像不會傳遞並加載到新視圖中。我想我正在犯一個不好的錯誤,只需要一點點指導。從webview推送和加載圖像在viewcontroller
這是代碼處理和推送視圖控制器。
//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的代碼從web視圖..
//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];
}
}
只是要回到此處。我最終弄清楚了這一點。目前不需要進一步的幫助。 – ChrisOSX