如何将标签拖放到自动填充文本字段?

时间:2015-04-19 03:15:09

标签: ios objective-c iphone xcode6

我想拖放一个标签或自动完成UITextfield的东西。例如,如果我有一个空的文本字段,我拖动带有文本的标签" hello world"在文本字段的顶部,文本字段将具有" hello world"作为其文本。有谁知道我怎么做到这一点? UILabel是最好的选择吗?或者也许UIButton可以工作?

2 个答案:

答案 0 :(得分:0)

您最好先阅读有关IOS开发的教程。按照教程

在此网站http://www.appcoda.com/ios-programming-course/

对于您的问题研究,首先会出现以下链接

http://www.appcoda.com/hello-world-build-your-first-iphone-app/
http://www.appcoda.com/ios-programming-basic-how-does-the-hello-world-app-work/

答案 1 :(得分:0)

试试这个

-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
   //get position
   // get label on that position
   [label removeFromSuperView];
   newLabel = [[UILabel alloc] init]; 
   [self.view addSubView:newLabel]; //positioned at label
}

touchesMoved {
   //getPosition
   newLabel.position = position;
}

touchesEnded {
   //getPosition.
   self.view.subviews; // loop and find which view has the position.

   UILabel *finalLabel = [[UILabel alloc] init];
   finalLabel.center = newLabel.center;

   [newLabel removeFromSuperView];

   [viewToBeDroppedOn addSubview:finalLabel];
}

另请参阅本教程Drag & Drop