2011-04-19 82 views
0

我想显示一个弹出对话框来通知用户服务器数据正在从iPad应用程序访问,特别是在分割视图控制器的顶部。用模态显示的单独控制器来做到这一点是最好的方法吗?视图控制器指南指出模式视图控制器是全屏转换,所以在iPad应用程序中不经常使用,所以我想知道是否有更好的方法,因为我只是想创建一个带有活动指示符的半透明背景,信息。在iPad上显示弹出对话框

但是,我不想仅仅使用分割视图的两个控制器之一,因为它似乎不是正确的方法。

回答

0

你可以用UIAlertView来做到这一点。

UIAlertView *alert; 

... 

alert = [[[UIAlertView alloc] initWithTitle:@"Accessing Data..." 
      message:nil delegate:self cancelButtonTitle:"Cancel" otherButtonTitles: nil] autorelease]; 

[alert show]; 

HERE他们讨论没有按钮的设置,所以你可以控制,当你想关闭它(如果你想防止用户同时该服务器数据被访问的交互)。基本上你结束了:

[alert dismissWithClickedButtonIndex:0 animated:YES]; 

希望帮助:

UIAlertView *alert; 

... 

alert = [[[UIAlertView alloc] initWithTitle:@"Accessing Data..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease]; 
[alert show]; 

UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 

// Adjust the indicator so it is up a few pixels from the bottom of the alert 
indicator.center = CGPointMake(alert.bounds.size.width/2, alert.bounds.size.height - 50); 
[indicator startAnimating]; 
[alert addSubview:indicator]; 
[indicator release]; 

这里面有活动的指标警报视图,您可以用解雇。

+0

如果宽度/高度为零,请在willPresentAlertView委托方法中添加该指标。 – LEO 2013-10-26 16:08:19