Very new to iphone development and i cant seem to figure out why this is happening. im pretty sure it has somthing todo with the fact that with boardView is nill it creates a new one. but im applying the image to the newly formed imageView so im not sure whats going on.
like i said, everything works. i get my list of items click on an item and it goes to the next page with the correct image (EXCEPT the very first time).
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger row = [indexPath row];
if(self.boardView == nil){
BoardView *aboardView = [[BoardView alloc]initWithNibName:@"BoardView" bundle:nil];
self.boardView = aboardView;
[aboardView release];
}
NSString *filePath = [[NSBundle mainBundle] pathForResource:[snowBoardArray objectAtIndex:row] ofType:@"png"];
UIImage *theImage = [[UIImage alloc] initWithContentsOfFile:filePath];
self.boardView.imageView.image = theImage;
[theImage release];
[self.navigationController pushViewController:self.boardView animated:YES];
}
boardView is almost a blank UIViewController with the exception of having the added imageView
You can add this line although its bit of a hack. You have to just access viewcontroller’s view so that its created. You can avoid compiler warning by modifying any of the views property. I would suggest to do the following.
I had this issue and all you have to do is call the view to be created. Even though a simple line like
self.boardView.view;should suffice, to avoid the compiler warning change the hidden property.