views:

28

answers:

1

Hi,

I have a project where a UITextView (for multilines) can be dragged around the screen. So far my solution to this has been an overlay of an invisible UIButton which when dragged its center is the same as the UITextView's center.

However I've seen apps that seem to just allow the UITextView to be dragged and edited on the fly so it seems there might not be an overlay in those but I'm not sure.

Thoughts?

By the way, c in this code is the UIButton and this is how I have moved it thus far:

- (void) draggedOut: (UIControl *) c withEvent: (UIEvent *) ev 
{

 if(self.interfaceOrientation == UIInterfaceOrientationPortrait)
 {
  c.center = [[[ev allTouches] anyObject] locationInView:self.view];
  AddedText.center = c.center;
 }
 else if(self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown)
 {
  c.center = [[[ev allTouches] anyObject] locationInView:self.view];
  AddedText.center = c.center;
 }
 else if(self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft)
 {
  c.center = [[[ev allTouches] anyObject] locationInView:self.view];
  AddedText.center = c.center;
 }
 else if(self.interfaceOrientation == UIInterfaceOrientationLandscapeRight)
 {
  c.center = [[[ev allTouches] anyObject] locationInView:self.view];
  AddedText.center = c.center;
 }
}
A: 

Well have not been able to manipulate the actual uitextview.

First tried making a button overlay that could be moved and could be pressed to start editing, but it wasn't centered properly.

Then tried the above method to move the UITextView itself. But it would only work on touches or drags. (Note this was a modified form of touchesBegan & touchesMoved)

Ended up with a UIScrollView with the UITextView as a subview. Now it can move smoothly just that it can be moved from any place on the screen. Not optimal but is the best result to thus keep everything else intact.

Ebon