【问题标题】:focus on UITextField then select UIButton xcode专注于 UITextField 然后选择 UIButton xcode
【发布时间】:2015-07-15 11:29:48
【问题描述】:

当我专注于 UITextField 时,我想在 UITableview 中的 UITextField 前面更改 UIButton 的图像。有可能吗?

【问题讨论】:

    标签: xcode uitableview uibutton uitextview


    【解决方案1】:

    您可以通过实现UITextFieldDelegate 方法textFieldDidBeginEditing: 在您的UITextField 获得焦点时收到通知。

    textField.delegate = self;
    

    实现此方法后,获取正确UIButton的引用并像这样更改所需的图像。

    -(void)textFieldDidBeginEditing:(UITextField *)sender{
        [yourButton setImage:newImage forState:UIControlStateNormal];
    }
    

    【讨论】:

    • 我的按钮在 UITableView 中是动态创建的。请检查我的问题。
    • 要获取表格视图中动态创建的按钮的引用,您可以使用标签。然后在 didBeginEditing 方法中,你可以从你的标签中获取按钮。
    • 为什么不更新您的答案以显示完整的示例?
    猜你喜欢
    • 2011-02-19
    • 2015-02-18
    • 2013-09-23
    • 2016-10-31
    • 1970-01-01
    • 2012-07-20
    • 2017-06-13
    • 1970-01-01
    • 2015-02-27
    相关资源
    最近更新 更多