0
我有2個UIViews(placardView和PlacardView2),我想限制他們時觸摸水平移動但不垂直使用touchesMoved方法。我的想法是讓Y座標等於自己,但是我不能在Xcode中使用語法,因爲我對這類事情很陌生。水平移動一個UIView
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
UITouch *touch = [touches anyObject];
// If the touch was in the placardView, move the placardView to its location
if ([touch view] == placardView) {
CGPoint location = [touch locationInView:self];
placardView.center = location;
placardView.center.y = placardView.center.y;//error is here
return;
}
if ([touch view] == placardView2) {
CGPoint location = [touch locationInView:self];
placardView2.center = location;
placardView2.center.y = placardView2.center.y;//error is here
return;
}
}
謝謝SVD!看起來像這樣做後,我評論該行(placardView2.center =位置;)出並代之以你的代碼....我不知道爲什麼我有如此難以形象化。 :) –