【发布时间】:2011-05-15 22:44:31
【问题描述】:
我正在开发一款横向 iPhone 应用。它在 iPhone 上运行良好,但是当我在 iPad 或 iPad 模拟器上运行它时,它在处理 x 方向超过 320 的触摸时遇到问题。
许多超过 320 的 UIButton 在按下时会突出显示,但不会执行它们的操作。
当我将此添加到我的超级视图时:
- (void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event{
UITouch *touch = [touches anyObject];
CGPoint touchLocation = [touch locationInView:self];
NSLog(@"bounds: %1.2f %1.2f touch: %1.2f %1.2f",self.bounds.size.width,self.bounds.size.height,touchLocation.x,touchLocation.y);
}
它永远不会输出大于 320 的 x 值。任何大于 320 的屏幕按下的部分都会为 x 输出 320。
UIViews 都是以编程方式完成的,没有 UIViewControllers。我已将 plist 设置为以横向启动它,并在 applicationDidFinishLaunching 中旋转视图:
window.transform = CGAffineTransformMakeRotation((M_PI / 2.0));
window.bounds = CGRectMake(0, 0, 480, 320);
window.center = CGPointMake(160.0f, 240.0f);
[window makeKeyAndVisible];
感谢任何帮助。
【问题讨论】:
-
您是否将其构建为“通用应用程序”?当您为 iPad 构建它时,您是否首先按照步骤创建 .nib 文件的 iPad 版本?
-
不,我将其构建为仅适用于 iPhone 的应用程序。
-
window.bounds = CGRectMake(0, 0, 480, 320);将应用程序的边界设置为 480 和 320。所以我想你不能超出这个范围。
标签: iphone objective-c cocoa-touch ipad uiview