我有一个声明为
的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];
答案 0 :(得分:0)
试试这个
self.waitingDialog.title = @"new title";
[self.waitingDialog setNeedsDisplay];