我正在使用故事板开发一个iPad应用程序。在我的应用程序中,我具有两个文本字段和一个按钮的弹出视图。如果单击按钮,我需要做的就是在选定的文本框中显示一个文本。我如何找到当前情况下选中的文本框?下面给出示例代码,请帮助我完成功能。
- (IBAction)buttonPressed:(id)sender {
if(//Here i need to set the condition for check selected text box is first){
texbox1.text=@"User";
}
else{
textbox2.text =@"Admin";
}
}
- (IBAction)buttonPressed:(id)sender {
if([textbox1 isFirstResponder]){
//Cursor on textbox1
texbox1.text=@"User";
}
else if([textbox2 isFirstResponder]){
//Cursor on textbox2
textbox2.text =@"Admin";
}
else{
NSLog(@"None of them have cursor");
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系 [email protected] 删除。
我来说两句