【问题标题】:UIAlertView update titleUIAlertView 更新标题
【发布时间】:2014-01-20 14:30:53
【问题描述】:

我有一个 UIAlertView,它被声明为

-(UIAlertView *)waitingDialog {
    if (!_waitingDialog) {
        _waitingDialog = [[[UIAlertView alloc] initWithTitle:@"" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];
    }
    return _waitingDialog;
}

show方法声明为:

-(void)showWaitingDialogWithText:(NSString *)text {
    [self.waitingDialog setTitle:text];
    [self.waitingDialog show];
    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

    indicator.center = CGPointMake(self.waitingDialog.bounds.size.width / 2, self.waitingDialog.bounds.size.height - 50);
    [indicator startAnimating];
    [self.waitingDialog addSubview:indicator];
    [indicator release];
}

问题是:如何更新标题? 我尝试了以下但它不起作用。标题保持不变:

[self.waitingDialog setTitle:newTitle];
CGRect waitingFrame = self.waitingDialog.frame;
UILabel *alertLabel = [self.waitingDialog.subviews objectAtIndex:1];
CGRect waitingLabelFrame = alertLabel.frame;

[UIView animateWithDuration:0.15 delay:0.4 options:(UIViewAnimationCurveEaseIn) animations:^{
   [self.waitingDialog setFrame:waitingFrame];
    alertLabel.frame = waitingLabelFrame;

} completion:nil];

【问题讨论】:

    标签: ios objective-c uialertview


    【解决方案1】:

    试试这个

    self.waitingDialog.title = @"new title";
    [self.waitingDialog setNeedsDisplay];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-08-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-04-07
      相关资源
      最近更新 更多