簡體   English   中英

如何將標簽拖放到自動完成的文本字段?

[英]How do I drag and drop a label to autocomplete textfield?

我想拖放標簽或將自動完成UITextfield的東西。 例如,如果我有一個空的文本字段,並且在文本字段頂部拖動了一個文本為“ hello world”的標簽,則該文本字段將以“ hello world”作為其文本。 有人知道我該怎么做嗎? UILabel是使用的最佳選擇嗎? 也許UIButton可以工作?

您最好先閱讀有關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/

嘗試這個

-(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];
}

還要檢查本教程拖放

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM