简体   繁体   English

在View(iOS)的底部边缘触摸不注册

[英]Touch not registering at bottom edge of View (iOS)

I am experimenting with a fullscreen OpenGL ES 2 based app for the iPhone. 我正在尝试针对iPhone使用基于全屏OpenGL ES 2的应用程序。

I have it working, but for some reason I am unable to draw on the bottom 16px of the app. 我可以使用它,但是由于某种原因,我无法在应用程序的底部16px上绘图。

在此处输入图片说明

Note: 注意:

  • I drew each of the lines by dragging my finger along the very edge of the screen. 我通过沿着屏幕的边缘拖动手指来绘制每条线。

  • Touching anywhere in the bottom 16px registers as touching at 16px. 底部16px的寄存器随时随地触摸截至 16px的接触。

  • If I touch above the bottom 16px, the touches and the strokes show up at the right place. 如果我在底部16像素上方触摸,则触摸和笔触会显示在正确的位置。

  • I am testing on iOS 7.1 iPhone 5S. 我正在iOS 7.1 iPhone 5S上进行测试。

Why would this be? 为什么会这样呢? Here's what my pretty standard touch handling code looks like: 这是我相当标准的触摸处理代码,如下所示:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{

    CGRect     bounds = [glView bounds];
    UITouch*    touch = [[event touchesForView:glView] anyObject];
    CGFloat scale = glView.contentScaleFactor;

    CGPoint touch_location = [touch locationInView:glView];
    touch_location.y = (bounds.size.height - touch_location.y);

    touch_location.x *= scale;
    touch_location.y *= scale;

    //... draw stuff etc.
}

It turns out that there is no real solution to this. 事实证明,对此没有真正的解决方案。 I looked at some other painting applications on the app store and none of them draw on the edges. 我在应用商店上查看了其他绘画应用程序,但没有一个画在边缘。 For symmetry most of them don't draw on the bottom and on the top 16px or so. 为了对称起见,大多数都不会在底部顶部绘制16px左右。 I ended up doing the same. 我最终做了同样的事情。

In your project status bar is hidden. 在您的项目状态栏中是隐藏的。

If so then you need to add +20 to your view as status bar is not there. 如果是这样,则您需要在视图中添加+20,因为状态栏不存在。 For eg if you have view controller with status bar in say iPhone then in portrait mode height will be 460. But if status bar is hidden then we have to set it 480. 例如,如果您说的是带有iPhone状态栏的View Controller,那么在纵向模式下,高度将为460。但是如果状态栏被隐藏,则必须将其设置为480。

This is certainly because of the swipe gesture for the control center in iOS7. 当然,这是因为iOS7中控制中心的滑动手势。 I had the same problem regarding an UIButton (see here ) 关于UIButton,我遇到了同样的问题(请参阅此处

In your case you could try to add prefersStatusBarHidden : 在您的情况下,您可以尝试添加preferredsStatusBarHidden:

- (BOOL)prefersStatusBarHidden {
    return YES;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM