检测选择器视图的宽度和高度
如何检测选择器视图的宽度和高度以便可以正确放置它?我想使用边界,但不知道如何准确地做到这一点。谢谢。
durationPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,244,320,400)];
how do you detect the width and height of a picker view so that it can be placed appropriately? I'd like to use bounds, but can't figure out how to do it exactly. Thanks.
durationPicker = [[UIPickerView alloc] initWithFrame:CGRectMake(0,244,320,400)];
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
在你的例子中,宽度是 320,高度是 400,但是对于任何
UIView
,你可以使用myview.frame.size.width
获取宽度和高度,并且分别是myview.frame.size.height
。因此 nslog 可能类似于:如果您想要边界而不是框架,请替换上面代码中“frame”所在的“bounds”。
Well in your case, the width is 320 and the height is 400, but for any
UIView
, you can get the width and height withmyview.frame.size.width
andmyview.frame.size.height
, respectively. so an nslog might be something like:If you want the bounds instead of the frame, substitute "bounds" where "frame" is in the above code.