Iphone 如何在单击UIButton时添加UITextfield并使其可编辑
我有一个UIButton,我试图在点击UIButton后开发一个可编辑的UIExtField。 基本上,我希望用户点击按钮,编辑文本并保存以备将来使用 因此,目前我有:Iphone 如何在单击UIButton时添加UITextfield并使其可编辑,iphone,objective-c,uibutton,uitextfield,Iphone,Objective C,Uibutton,Uitextfield,我有一个UIButton,我试图在点击UIButton后开发一个可编辑的UIExtField。 基本上,我希望用户点击按钮,编辑文本并保存以备将来使用 因此,目前我有: [notes_button addTarget:self action:@selector(editNote) forControlEvents:UIControlEventTouchUpInside]; 我不知道如何获得一个像UITextField onclick这样的弹出窗口,并在editNote函数中添加UITextFi
[notes_button addTarget:self action:@selector(editNote) forControlEvents:UIControlEventTouchUpInside];
我不知道如何获得一个像UITextField onclick这样的弹出窗口,并在editNote函数中添加UITextField。试试这个。首先在viewdidload上隐藏文本字段,然后在按下按钮时淡入。。使其可编辑,并为用户弹出键盘
//viewDidLoad
yourTextField.alpha = 0;
yourTextField.userInteractionEnabled = FALSE;
-(void)editNote {
//fade in text field after button push
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDelay:0];
[UIView setAnimationDuration:0.75];
yourTextField.alpha = 1;
[UIView commitAnimations];
//make text field editable
yourTextField.userInteractionEnabled = TRUE;
//pop up keyboard
[yourTextField becomeFirstResponder];
}
----更新-----
现在你已经描述了你想做得更好一点的事情。您需要在此新的视图控制器上创建一个全新的视图控制器,其中包含字段(UITextFields等)
单击按钮,您将编码:
TextFieldViewController * vc = [(TextFieldViewController *)[[TextFieldViewController alloc] init] autorelease];
[self.navigationController presentModalViewController:vc animated:YES];
[vc release];
//you will need to create a button on this new ViewController and use this code to dismiss it when done.
[[self parentViewController] dismissModalViewControllerAnimated:YES];
是否希望在用户按下notes_按钮后,uitextfield变为可编辑?或者它应该出现在那一点上?在用户按下notes_按钮后,一个uitextfield应该出现并且应该是可编辑的。我想我没有正确地框定我的问题。我真的想要类似Yelp的东西,它有“写评论”按钮。单击该按钮,它将显示一个可编辑的草稿a审阅页面,您可以将其保存。在textviewcontroller中,我需要开发带有可编辑文本字段rite的UITextView?是的,以及一个按钮,以便您可以在完成后关闭该视图。“保存”按钮可以正常工作。保存后关闭它。为什么在代码中使用TRUE和FALSE?目标C对布尔类型使用是和否