以供参考:
@interface rjhccViewController : UIViewController{
int myInt;
IBOutlet UIImageView *testcontainer;
IBOutlet UILabel *heightS;
IBOutlet UILabel *widthS;
}
-(IBAction) img1;
-(IBAction) img2;
@end
-(IBAction)img1{
UIImage *img = [UIImage imageNamed:@"p.jpeg"];
[testcontainer setImage:img];
[testcontainer setFrame:CGRectMake(0,0,50,50)];
int myInt = (int) img.size.height;
NSString *imgheight = [NSString stringWithFormat:@"%i",[[NSNumber numberWithFloat:img.size.height] intValue]];
heightS.text = imgheight;
}
所以我把它附加到一个按钮上。当我单击按钮时,图像会显示并报告高度,但容器不会改变大小。当我再次单击该按钮时,它确实转到了 CGRectMake 的正确位置……不知道为什么?
抢