Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 10-24-2010, 10:03 AM   #1 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 4
TranT is on a distinguished road
Default UIImageView not showing image!

Hey! I have TableView with several cells and when I click on one it goes to a simple View with only a UIImageView on it. The problem is that on the first click the image on the View doesn't show up only in the next clicks.

Code:

Code:

@interface ImageViewerViewController : UIViewController {
	IBOutlet UIImageView *imageView;
}

@property (nonatomic,retain) UIImageView *imageView;

@end





- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
	
	if(childViewerController==nil)
		childViewerController= [[ImageViewerViewController alloc] initWithNibName:@"ImageViewer" bundle:nil];
	
	UIImage *image = [UIImage imageNamed:@"images.jpg"];
	childViewerController.imageView.image=image;

	WebMedicalImageViewerAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
	[delegate.navController pushViewController:childViewerController animated:YES];
}
Image showing UI:
example.png - ImageHost.org

Any idea why ?
TranT is offline   Reply With Quote
Old 10-24-2010, 10:48 AM   #2 (permalink)
Registered Member
 
Join Date: Aug 2010
Posts: 236
moezzz is on a distinguished road
Default

Quote:
Originally Posted by TranT View Post
Hey! I have TableView with several cells and when I click on one it goes to a simple View with only a UIImageView on it. The problem is that on the first click the image on the View doesn't show up only in the next clicks.

Code:

Code:

@interface ImageViewerViewController : UIViewController {
	IBOutlet UIImageView *imageView;
}

@property (nonatomic,retain) UIImageView *imageView;

@end





- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    // Navigation logic may go here. Create and push another view controller.
	
	if(childViewerController==nil)
		childViewerController= [[ImageViewerViewController alloc] initWithNibName:@"ImageViewer" bundle:nil];
	
	UIImage *image = [UIImage imageNamed:@"images.jpg"];
	childViewerController.imageView.image=image;

	WebMedicalImageViewerAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
	[delegate.navController pushViewController:childViewerController animated:YES];
}
Image showing UI:
example.png - ImageHost.org

Any idea why ?


try to use .png file where possible...
moezzz is offline   Reply With Quote
Old 10-24-2010, 12:24 PM   #3 (permalink)
N3RD
 
Join Date: Oct 2009
Posts: 201
tychop is on a distinguished road
Default

Can you be more specific?
Does the tableview>view animation show up on a second click?
Is the image just not showing or is the view not pushed on the stack?
When you debug & stop just before the push on the navController, is you controller valid? Is the image valid?

First guess: I think the 'imageNamed' method generates cached images. You might want to alloc init an image (don't forget to release). Maybe that's your problem.
tychop is offline   Reply With Quote
Old 10-25-2010, 09:33 AM   #4 (permalink)
Registered Member
 
Join Date: Sep 2010
Posts: 4
TranT is on a distinguished road
Default

The table is working fine but when i click one of the cells for the first time the image on the View that shows up doesn't appear. I go back with the nav button to the table again, click another cell and voilą it shows the image on the View.

I tried to alloc the image ( and release it but when i did the release the app would crash :s ) and I have the same problem.

Code:
	NSString *myImagePath = [[[NSBundle mainBundle] resourcePath]  stringByAppendingPathComponent:@"images.jpg"];
	UIImage *image = [[UIImage alloc] initWithContentsOfFile:myImagePath];
TranT is offline   Reply With Quote
Old 12-04-2010, 11:15 AM   #5 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 4
rc20rd is on a distinguished road
Default I have the same problem with you

Hi,
do your problem solve?
if solved, please tell me
thank you
rc20rd is offline   Reply With Quote
Old 12-04-2010, 11:24 AM   #6 (permalink)
Registered Member
 
Join Date: Jan 2009
Posts: 60
substance21 is on a distinguished road
Default

This is most likely due to imageView being nil when you are setting it for the first time. This is because alloc/init on a viewController doesn't load the view; it gets loaded when the view is about to be displayed.

You can either explicitly load the view using the loadView method (not really sure if this has side effects), or set some other retained UIImage property in the controller, and in the viewDidLoad method of your view controller, set the imageView from that.
__________________
iPhoneApps:
enLegion - When everyone needs to be in the same place, but isn't
AutoWeb - Automate your web logins and browsing!
substance21 is offline   Reply With Quote
Old 12-04-2010, 11:45 AM   #7 (permalink)
Registered Member
 
Join Date: Nov 2010
Posts: 4
rc20rd is on a distinguished road
Default

Quote:
Originally Posted by moezzz View Post
try to use .png file where possible...
Hi ,buddy
try this :
- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath {
// Navigation logic may go here. Create and push another view controller.

if(childViewerController==nil)
childViewerController= [[ImageViewerViewController alloc] initWithNibName:@"ImageViewer" bundle:nil];

WebMedicalImageViewerAppDelegate *delegate = [[UIApplication sharedApplication] delegate];
[delegate.navController pushViewController:childViewerController animated:YES];

UIImage *image = [UIImage imageNamed:@"images.jpg"];
childViewerController.imageView.image=image;
}
rc20rd is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 321
12 members and 309 guests
chiataytuday, condor304, Desert Diva, Domele, dre, dreamdash3, mottdog, oceanlablight, palme2elie, Paul Slocum, schmallegory
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,659
Threads: 94,118
Posts: 402,895
Top Poster: BrianSlick (7,990)
Welcome to our newest member, dreamdash3
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 01:15 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0