1

Being new to objective-C but tinkering I was trying out dragging with the iPad, and the following code from my viewcontroller.m works okay in portrait, but not in landscape:

-(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 being the default view that was created with the app, and testViewToMove being a UIView I made for kicks.

In landscape, the coordinates don't seem to translate. I'm sure this is something obvious, but I don't get it, what's going on here?

I tried setting the view to landscape, and tinkering with some other settings to no avail... I also saw this, but to my own dismay I haven't been able to get it to work.

Community
  • 1
  • 1
Jane Panda
  • 1,591
  • 4
  • 23
  • 51
  • 1
    Well, the answer provided in that other question you mention really should solve your problem. What exactly is giving you trouble implementing that code? – MiguelB Aug 08 '11 at 21:30
  • Tweaking at it with fresh eyes, it seems to be working now – Jane Panda Aug 08 '11 at 22:41

1 Answers1

1

Seems I just needed to change mainView.superview to self.view in the first method, after applying the fix linked above.

Jane Panda
  • 1,591
  • 4
  • 23
  • 51