当用户在文本字段中输入值后,按钮应该是可见的 [英] The buttons should be visible when the user is done entering the value in the textfield

查看:65
本文介绍了当用户在文本字段中输入值后,按钮应该是可见的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个文本字段和两个按钮,在用户开始输入第二个文本字段或用户完成在第二个文本字段中的输入之前,该按钮不可见.谢谢,

I have two textfields and two buttons and the button should not be visible till the user starts entering into the second textfield or the user has done entering in the second textfield. Thanks,

- (void)textFieldDidBeginEditing:(UITextField *)secondFIB
{
    if (secondFIB.tag == 1703) {

        [self addPlusButton:[UIImage imageNamed:@"addButton1.png"] andFrameX:25 andFrameY:443 andFrameW:54 andFrameH:54];
        [self addNextButton:[UIImage imageNamed:@"scenariosButton_active_green.png"] andTitle:@"Next." andFrameX:475 andFrameY:443 andFrameW:234 andFrameH:54];
        /*UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(insertNewObject)];
        self.navigationItem.rightBarButtonItem = addButton;
        [addButton release];*/
    }
}

我这样做了,但是没用.我是否需要在其他任何地方添加此委托方法?

I did this but it doesn't work. Do I need to add this delegate method anywhere else?

推荐答案

设置UITextFieldDelegates,并标记textFields(button.tag = someNumber;

Set the UITextFieldDelegates, and tag the textFields (button.tag = someNumber;

- (void)textFieldDidBeginEditing:(UITextField *)textField
{
    if (textField.tag == someNumberOftheOneYouWant) {
        // show Save Button
        UIBarButtonItem *addButton = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemSave target:self action:@selector(insertNewObject)];
        self.navigationItem.rightBarButtonItem = addButton;
        [addButton release];
    }
}

或类似的东西...当光标位于另一个文本字段中时,您必须将按钮设置为nil.

Or something like that... You'll have to set the button to nil when the cursor is in the other textfield.

UITextFieldDelegates的列表

List of UITextFieldDelegates

textFieldShouldBeginEditing:
textFieldDidBeginEditing:
textFieldShouldEndEditing:
textFieldDidEndEditing:

textFieldShouldBeginEditing:
textFieldDidBeginEditing:
textFieldShouldEndEditing:
textFieldDidEndEditing:

textField:shouldChangeCharactersInRange:replacementString:
textFieldShouldClear:
textFieldShouldReturn:

textField:shouldChangeCharactersInRange:replacementString:
textFieldShouldClear:
textFieldShouldReturn:

这篇关于当用户在文本字段中输入值后,按钮应该是可见的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆