문제

I am experimenting with a fullscreen OpenGL ES 2 based app for the iPhone.

I have it working, but for some reason I am unable to draw on the bottom 16px of the app.

enter image description here

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.

  • If I touch above the bottom 16px, the touches and the strokes show up at the right place.

  • I am testing on 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. 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. For e.g 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.

This is certainly because of the swipe gesture for the control center in iOS7. I had the same problem regarding an UIButton (see here)

In your case you could try to add prefersStatusBarHidden :

- (BOOL)prefersStatusBarHidden {
    return YES;
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top