【发布时间】:2012-12-02 21:12:53
【问题描述】:
供参考:
@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...不知道为什么?
罗伯
【问题讨论】:
-
testcontainer 是
UIImageView吗? -
是的...我已经在 Objective-C 和 Cocoa 领域待了 2 天了。对这个来说相当新。
标签: xcode cocoa-touch uiimageview