Iphone UIImageView';s的宽度设置失败
我在Size Inspector中将UIImageView的宽度设置为0Iphone UIImageView';s的宽度设置失败,iphone,ios,cocoa-touch,uiimageview,Iphone,Ios,Cocoa Touch,Uiimageview,我在Size Inspector中将UIImageView的宽度设置为0 -viewDidLoad { ... //smallTiao is the outlet of UIImageView NSLog(@"smallTiao 's width %f",self.smallTiao.frame.size.width); } Xcode日志小条的宽度为0.000000 但实际上,在iPad模拟器中,图像视图的宽度不是0。我不知道为什么 更新 问题解决了。我删除了图像视图。我添加了一
-viewDidLoad
{
...
//smallTiao is the outlet of UIImageView
NSLog(@"smallTiao 's width %f",self.smallTiao.frame.size.width);
}
Xcode日志小条的宽度为0.000000
但实际上,在iPad模拟器中,图像视图的宽度不是0。我不知道为什么
更新
问题解决了。我删除了图像视图。我添加了一个新的图像视图。然后一切正常。您设置0和获得0.0000000并不都是一样的,(减去int和float)?您是从代码创建图像视图还是使用“蹩脚”界面生成器?@H2CO3我在Interface Builder中创建图像视图。为什么要使用0宽度的图像视图?@Nimingzheze2008,您确定它已正确连接到类的实际属性吗?如果不是,则
self.smallTiao
为nil
,由此发送给它的任何其他消息返回0。