【问题标题】:Can't figure out iPad landscape view coordinates无法计算 iPad 横向视图坐标
【发布时间】:2011-10-22 01:56:37
【问题描述】:

作为 Objective-C 的新手,但我正在尝试用 iPad 拖动,我的 viewcontroller.m 中的以下代码在纵向上可以正常工作,但在横向上不行:

-(void) touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {    
UITouch *touch = [[event allTouches] anyObject];
CGPoint location = [touch locationInView:mainView.superview];
testViewToMove.center = location;
}

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
[self touchesBegan:touches withEvent:event];
}

mainView 是使用应用程序创建的默认视图,而 testViewToMove 是我为踢球而制作的 UIView。

在横向中,坐标似乎没有平移。我确定这很明显,但我不明白,这是怎么回事?

我尝试将视图设置为横向,并修改了一些其他设置无济于事...我还看到了this,但令我沮丧的是,我无法让它工作。

【问题讨论】:

  • 好吧,您提到的其他问题中提供的答案确实应该可以解决您的问题。究竟是什么让您难以实现该代码?
  • 用新鲜的眼光调整它,它现在似乎正在工作

标签: xcode ipad xcode4


【解决方案1】:

似乎我只需要在第一种方法中将 mainView.superview 更改为 self.view,在应用上面链接的修复程序之后。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-11-05
    相关资源
    最近更新 更多