开发者

UIView frame.size.width is equal to zero?

I created a subclass of UIView and within the subclass I try to access the views' width property. I try to get the width like this,

CGFloat width = self.frame.size.width;
NSLog(@"Width: %f", width);

However for some reason the width I'm getting is equal to 0.000000

When I create the view I'm setting the frame proper开发者_如何学Cty using the CGRectMake() function and the view is clearly displaying properly so why would the width property return zero?


If you subclass UIPickerView, irrespective of the frame you set, width and height are 320,216 (for Portrait).
Make sure self in your code points to the picker.


Try CGFloat width = self.view.frame.size.width;


Have you tried this @cgossain?

CGFloat width = CGRectGetWidth(self.view.bounds);
CGFloat height = CGRectGetHeight(self.view.bounds);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜