Programmatically added UIImageView won't show up
I've been trying for an hour and nothing I do can seem to make this show the image:
UIImageView*logo=[[UIImageView alloc] initWithImage:[UIImage imageNamed: @"logo.png"]];
logo.frame=pos; // a CGRect I previously created
self.taskbarlogo=logo;
[logo release];
[self.popupwindow addSubview:self.taskbarlogo];
logo.png is definitely there in the project
this is the last subview added to self.popupwindow
so it should be on top
the hidden
property is never handled anywhere so it should be visible
The following NSLog
confirms the placement of the UIImageView's frame:
NSLog(@"frame: %f %f %f %f",self.taskbarlogo.frame.origin.x,self.taskbarlogo.frame.origin.y, self.taskbarlogo.frame.size.width, self.taskbarlogo.frame.size.height);
It re开发者_运维百科ports:
frame: 20.000000 20.000000 96.000000 33.000000
this is certainly onscreen, or certainly should be as my superview's frame is much larger than this
what am I missing?! there is no crash, no errors, just.... no image.
Check the file inspector (one of the right side tabs) under Target Membership and make sure the image belongs to all targets where the resource is desired. Also call bringSubviewToFront to be sure it's on top.
does it happen in iDevice AND in simulator?
try to delete the folder "build" in you project folder.
control that your file is checked for export as resource in xcode.
try menu:build:clean (and clean all target)
精彩评论