帧大小和坐标关闭(objective-c、ipad)
假设这是一个 10 x 10 的正方形,x 轴上距离原点 100 个像素,y 轴上距离原点 100 个像素(原点是左上角) 然而,这显然是错误的。
设置后将视图框架写入 NSLog,它会给出与我输入的值相同的值。
代码:
ISScrollDock *bottomSV = [[ISScrollDock alloc] init];
[bottomSV.view setFrame:CGRectMake(100, 100, 10, 10)];
[bottomSV.view setBackgroundColor:[UIColor redColor]];
[self.view addSubview:bottomSV.view];
这是一个 Xcode项目来显示我的问题:http://www.qfpost.com/download.do?获取=92f03538907e72665ea794d98ff8392b
Supposedly this is a 10 by 10 square 100 pixels on the x axis from the origin and 100 pixels on the y axis from the origin (origin being the top left corner)
However it quite clearly wrong.
Writing the views frame to NSLog after setting it gives out the same values I put in.
Code:
ISScrollDock *bottomSV = [[ISScrollDock alloc] init];
[bottomSV.view setFrame:CGRectMake(100, 100, 10, 10)];
[bottomSV.view setBackgroundColor:[UIColor redColor]];
[self.view addSubview:bottomSV.view];
Here is an Xcode project to show my problem: http://www.qfpost.com/download.do?get=92f03538907e72665ea794d98ff8392b
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
只需添加即可
,因为您的视图当前启用了
autoresizingMask
。Just add
because your view currently has
autoresizingMask
on.您是否将此滚动视图添加到另一个视图或已向上滚动的滚动视图?检查超级视图的帧位置。
Are you adding this scroll view to another view or scroll view which has been scrolled up? Check the frame location of the superview.
取消选中 xib 文件中的“自动调整子视图大小”。
现在,我的蛋糕在哪里? :P
Uncheck "Autoresize Subviews" in your xib file.
Now, where's my cake? :P