Ben
Ben

Reputation: 213

UITextField placeholder text not disappearing when actionsheet is dismissed

I have a UITextField set up in a TableView. When you first click on the textfield the placeholder text disappears like it is suppose too; but on the screen I have an actionSheet that is presented and when it is dismissed the placeholder text re-appears and no longer disappears in the textview.

Part of tableview cellForRowAt function:

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];
}

Upvotes: 0

Views: 1471

Answers (1)

ChenXin
ChenXin

Reputation: 373

You should not create a new textfield if one textfield has been add to the cell.

Upvotes: 1

Related Questions