【发布时间】:2015-03-19 22:19:54
【问题描述】:
我们正在尝试以编程方式将 UIView(FB Like 按钮)添加到我们游戏在 iOS 上的主视图(* 游戏是使用 Unity 构建的)。
添加点赞按钮的代码:
like = [[FBLikeControl alloc] init];
// Calculate position.
int screenWidth = UnityGetGLViewController().view.bounds.size.width;
int screenHeight = UnityGetGLViewController().view.bounds.size.height;
int likeWidth = like.frame.size.width;
int likeHeight = like.frame.size.height;
int xPos = screenWidth - likeWidth;
int yPos = screenHeight - likeHeight;
like.frame = CGRectMake(xPos, yPos, likeWidth, likeHeight);
[UnityGetGLViewController().view addSubview:like];
在我们测试过的大多数设备上,这都能正常工作,并且在正确的位置(右下角)显示按钮。
在一些 iOS 设备(运行 iOS 6)上,按钮被剪切。看起来它的 frame.width 正好等于其正确大小的 0.5(一半)! 但只有宽度......
这可能是什么原因?这是 iOS 6 或特定设备的一些已知错误吗?还是我们的代码不正确?
【问题讨论】:
-
您看到的
width的值是多少?您确定您没有将frame与bounds混淆吗?
标签: ios objective-c iphone uiview ios6