1
作爲Objective-C的新手,但修補程序我嘗試着用iPad拖動,以下代碼從我的viewcontroller.m在縱向工作正常,但不在橫向:找不到iPad橫向視圖座標
-(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,但讓我感到沮喪的是我一直無法使它工作。
那麼,你提到的其他問題中提供的答案確實應該解決你的問題。究竟是什麼給你實現代碼帶來麻煩? – MiguelB
用新鮮的眼睛調整它,它似乎現在工作 –