我为 iOS 7 创建了一个子视图(看起来很像带有微调器的警报视图),并利用了来自 wimagguc 的 iOS 7 自定义警报视图(git 上的 ios-custom-alertview)。使用弧。我遇到的问题是我在处理时显示视图,然后在处理完成时调用关闭,但仍显示在屏幕上。
Connection.m(编辑)
UIActivityIndicatorView *aSpinnerCustom;
CustomIOS7AlertView *alertViewCustom;
- (void)showWaittingAlert:(BOOL)isShow {
NSString *ver = [[UIDevice currentDevice] systemVersion];
float ver_float = [ver floatValue];
// custom alert view for iOS 7 from AlertViewCustom folder
alertViewCustom = [[CustomIOS7AlertView alloc] init];
//spinner to be added to iOS 7 AlertView
aSpinnerCustom = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
//label to be used as subview to help text and spinner
alertTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 250, 75)];
//label of app name
UILabel *subTitleApp;
subTitleApp = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 250, 40)];
subTitleApp.text = APP_NAME;
subTitleApp.font = [UIFont boldSystemFontOfSize:16.0f];
subTitleApp.textAlignment = UITextAlignmentCenter;
subTitleApp.numberOfLines = 0;
//label of processing
UILabel *subTitle;
subTitle = [[UILabel alloc] initWithFrame:CGRectMake(0, 25, 250, 25)];
subTitle.text = @"processing...";
subTitle.font = [UIFont systemFontOfSize:14.0f];
subTitle.textAlignment = UITextAlignmentCenter;
//set height of spinner in custom alertview
aSpinnerCustom.frame = CGRectMake(round((alertTitle.frame.size.width - 25) / 2), round(alertTitle.frame.size.height - 30), 25, 25);
aSpinnerCustom.tag = 1;
// adding text and spinner to alertview
[alertTitle addSubview:aSpinnerCustom];
[alertTitle addSubview:subTitleApp];
[alertTitle addSubview:subTitle];
//adding label to custom alertview
[alertViewCustom setContainerView:alertTitle];
[alertViewCustom setButtonTitles:NULL];
if (isShow) {
[alertViewCustom show];
[aSpinnerCustom startAnimating];
NSLog(@"%@",@"showWaitingAlert Show iOS 7");
}else {
[alertViewCustom close];
[aSpinnerCustom stopAnimating];
NSLog(@"%@",@"showWaitingAlert Stop iOS 7");
}
}