iPad横向检测屏幕左侧部分的触摸功能 [英] iPad Landscape trouble detecting touches on lefthand portion of screen

查看:169
本文介绍了iPad横向检测屏幕左侧部分的触摸功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一款风景iPhone应用。它在iPhone上运行良好但是当我在iPad或iPad模拟器上运行时,它在处理x方向超过320的触摸时遇到问题。

I am working on a landscape iPhone app. It runs fine on the iPhone but when I run it on an iPad or the iPad simulator it has problems dealing with touches that exceed 320 in the x direction.

很多超过320的UIButtons会在按下时突出显示,但不会动作。

A lot of the UIButtons beyond 320 will highlight when pressed but won't do their action.

我将此添加到我的超级浏览中:

When I add this to my superviews:

- (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.

it will never output an x value greater than 320. Any part of the screen pressed that is greater than 320 gives an output of 320 for x.

UIViews全部以编程方式完成,没有UIViewControllers。我已经设置了plist以在横向和启动它启动它.DidFinishLaunching我用这个旋转视图:

The UIViews are all done programatically and without UIViewControllers. I have set the plist to start it in landscape and in the applicationDidFinishLaunching I rotate the views with this:

window.transform = CGAffineTransformMakeRotation((M_PI / 2.0));
window.bounds = CGRectMake(0, 0, 480, 320); 
window.center = CGPointMake(160.0f, 240.0f);
[window makeKeyAndVisible];

任何帮助表示赞赏。

推荐答案

我遇到了类似的问题,但我以编程方式创建Window,View和ViewController(因为它是使用OpenGL ES的游戏) 。

I had a similar problem but I create all programmatically Window, View and ViewController (because it was a game using OpenGL ES).

问题是我最初创建的窗口与视图的矩形相同。要解决它,只需以这种方式创建窗口:

The problem was that I originally created the window with the same rect as the view. To solve it just make the window in this way:

// Always create the window in Portrait mode
mpWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];

和viewController(创建视图):

and the viewController (who creates the View):

mpController = [[OViewController alloc] initWithFrame: CGRectMake(mPosX, mPosY, mWidth, mHeight)];
// After this line the view will rotate to landscape
[mpWindow addSubview:mpController.view];

希望这有帮助!

这篇关于iPad横向检测屏幕左侧部分的触摸功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆