单击更改UIButton文本

时间:2014-07-17 10:42:47

标签: ios objective-c xcode ios6

我有一个名为“删除”的按钮,用于从列表中删除单元格。当我点击该按钮时,我希望将我的按钮重命名为“完成”,完成编辑。帮助我。

2 个答案:

答案 0 :(得分:1)

试试这个:

- (void)viewDidLoad
    {
        [super viewDidLoad];
        [self.btn setTitle:@"Delete" forState:UIControlStateNormal];

    }

    - (IBAction)deleteBtn:(id)sender
{

    [UIView animateWithDuration:0.2 animations:^{
        //Do your delete action here;    
    }completion:^(BOOL finished)
     {
         [self.btn setTitle:@"done" forState:UIControlStateNormal];
     }];

}

答案 1 :(得分:0)

- (void)viewDidLoad
{
    [super viewDidLoad];

    [self.btn setTitle:@"Delete" forState:UIControlStateNormal];
}

- (IBAction)deleteBtn:(id)sender
{
    [UIView animateWithDuration:0.2 animations:^{
        //Do your delete action here;    
    }completion:^(BOOL finished)
    {
        [sender setTitle:@"done" forState:UIControlStateNormal];
    }];
}