我有一个情况我需要提醒用户下次访问该视图控制器是“数据加载”。
我已将此添加到FirstViewController按钮操作:
- (IBAction)showCurl:(id)sender {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Please Wait" message:@"Acquiring data from server" delegate:self cancelButtonTitle:@"OK!" otherButtonTitles:nil];
[alert show];
SecondViewController *sampleView = [[SecondViewController alloc] init];
[sampleView setModalTransitionStyle:UIModalTransitionStylePartialCurl];
[self presentModalViewController:sampleView animated:YES];
}
这是行不通的。 它加载到SecondViewController,只加载SecondViewController后弹出。
所以,我想在SecondViewController本身。 该SecondViewController由这是它要需要一段时间取决于Internet连接以下载的原因在远程服务器中提取数据。 所以我决定加入UIAlertView中的功能:
- (NSMutableArray*)qBlock{
UIAlertView *alert_initial = [[UIAlertView alloc]initWithTitle:@"Loading" message:nil delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert_initial show];
NSURL *url = [NSURL URLWithString:@"http://www.somelink.php"];
NSError *error;
NSStringEncoding encoding;
NSString *response = [[NSString alloc] initWithContentsOfURL:url
usedEncoding:&encoding
error:&error];
if (response) {
const char *convert = [response UTF8String];
NSString *responseString = [NSString stringWithUTF8String:convert];
NSMutableArray *sample = [responseString JSONValue];
return sample;
}
else {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"ALERT" message:@"Internet Connection cannot be established." delegate:self cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
return NULL;
}
这并不工作过。 而最糟糕的是,我试图关闭网络连接来看看第二警报弹出提醒用户,有没有互联网连接。 第二警报不工作过。