【问题标题】:UITextField placeholder text not disappearing when actionsheet is dismissed关闭操作表时 UITextField 占位符文本不会消失
【发布时间】:2012-03-16 02:56:22
【问题描述】:

我在 TableView 中设置了一个 UITextField。当您第一次单击文本字段时,占位符文本也会像假设的那样消失;但是在屏幕上我有一个显示的 actionSheet,当它被关闭时,占位符文本重新出现并且不再在 textview 中消失。

tableview cellForRowAt 函数的一部分:

if (indexPath.section == 0)
    {
        UITextField *name = [[UITextField alloc] initWithFrame:CGRectMake(20, 10, 290, 20)];
        [name setDelegate:self];
        if (nameLabel == nil) {
            name.placeholder = @"Enter a name";
        }
        name.returnKeyType = UIReturnKeyDone;
        [cell addSubview:name];
    }

- (void)dismissActionSheet
{
[self.actionSheet dismissWithClickedButtonIndex:0 animated:YES];
[self.addItemTableView deselectRowAtIndexPath:[self.addItemTableView indexPathForSelectedRow] animated:YES];
[addItemTableView reloadData];
}

【问题讨论】:

    标签: ios uitableview uitextfield


    【解决方案1】:

    如果已将一个文本字段添加到单元格,则不应创建新的文本字段。

    【讨论】:

    • 好的,我将它设置在我的 .h 文件中。那应该可以解决它。
    • 你是如何让它不创建新的文本字段的?这是我的问题:stackoverflow.com/questions/17560209/… 谢谢。
    猜你喜欢
    • 1970-01-01
    • 2018-12-30
    • 2018-02-13
    • 1970-01-01
    • 2017-06-15
    • 2016-05-10
    • 1970-01-01
    • 1970-01-01
    • 2012-08-02
    相关资源
    最近更新 更多