I have a TableView, when I click on a cell it pushes my class ImageViewController and displays an image. This is working great. The viewDidLoad method is here.
- (void)viewDidLoad
{
NSLog(@"ImageViewController Load");
NSLog(@"Image String: %@",imageString);
self.view.contentMode=UIViewContentModeCenter;
UIImage *im = [UIImage imageNamed:imageString];
if(im == nil){
NSLog(@"Image is NULL");
}
[image setImage:im];
self.title = @"View Image";
[super viewDidLoad];
}
imageString is defined as an NSString in the .h file. I'm using a StoryBoard and launch my ImageViewController by:
ImageViewController *imageViewController = [segue destinationViewController];
imageViewController.imageString = [[listData objectAtIndex:selectedIndex]objectForKey:@"image"];
I'm experience problems (the screen is black) when I try and view an image when clicking on a link within a UIWebView. Basically here the UIWebView contains all my content and I'd like to view an image when cliking on a link.
To achieve this I'm using the following method:
-(BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{
And launch the ImageViewController using the following javascript
window.location.href="eft://?type=image&path=Google.jpg";
Within the shouldStartLoadingWithRequest method I push the ImageViewController using the following:
ImageViewController *imageViewController =[[ImageViewController alloc]init];
imageViewController.imageString = path;
[self.navigationController pushViewController:imageViewController animated:YES];
The image isn't null as I perform a check and the path and type fields are correct but the screen is black. Rather than rely on the path and type fields I manually set these fields in the ImageViewController (for exmaple google.jpg) and it still shows a black screen when loading the controller from the UIWebView. If I load it from the table view it works perfectly???
Thanks in advance
I've found the answer, i need to init with storyboard reference