我有以下代码:
_loadingAlert = [[UIAlertView alloc] initWithTitle:ALERT_TITLE_LOADING
message:ALERT_MESSAGE_LOADING
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
[_loadingAlert setValue:indicator forKey:@"accessoryView"];
[_loadingAlert show];
结果:
我的目的是显示一个内部有加载指示器的警报视图,但结果是附加的屏幕截图。有人有想法吗?
答案 0 :(得分:0)
答案 1 :(得分:0)
尝试使用此代码(如@ A-Live建议的那样),您可以调整填充值以在活动指示器的底部添加更多空间。
_loadingAlert = [[UIAlertView alloc] initWithTitle:ALERT_TITLE_LOADING
message:ALERT_MESSAGE_LOADING
delegate:nil
cancelButtonTitle:nil
otherButtonTitles:nil];
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
indicator.autoresizingMask = UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleRightMargin;
indicator.translatesAutoresizingMaskIntoConstraints = YES;
[indicator startAnimating];
CGFloat padding = 15;
UIView *indicatorView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, indicator.frame.size.width, indicator.frame.size.width+padding)];
[indicatorView addSubview:indicator];
[_loadingAlert setValue:indicatorView forKey:@"accessoryView"];
[_loadingAlert show];