2011-05-09 67 views
0

我是Iphone开发的新人。我有一种形式,其中显示数据,我打电话给web服务。当该服务被调用时,它将从其他文件中解析出来,并且页面导航到'发送页面',其中这些数据显示在UITableview中。iphone-UIAlertview-UIIndicatorview

我也使用uiAtertview和UIIndicatorview两者用于显示进程正在进行。但问题是,当我点击按钮我打电话UIAtertView + UIIndicator但没有得到显示,并且数据也没有得到显示,,,

我的代码是

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Configuring Preferences\nPlease Wait.." message:nil delegate:nil cancelButtonTitle:nil otherButtonTitles:nil,nil]; 
[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]; 

self.ResultPage = [[ResultPage alloc] init]; 
[email protected]" Search "; 

// Here My Webservice Is Call From Another ViewController Class And That Class Display Data //InTo UITableVIew 

[self.ResultPage GetSearchResult:StrBookId : txtFPrice.text :txtTprice.text]; 
[alert dismissWithClickedButtonIndex:0 animated:YES]; 
[self.navigationController pushViewController: _ResultPage animated:YES]; 

请建议我....

感谢名单

+0

你确定你设置的指标视图中心的高度是否正确? – 2011-05-09 06:02:15

回答

3

您可以添加在警报视图中活动的指标并显示,当你调用Web service.I警报视图也做同样的当我打电话web服务。它锁定视图,以便用户不能点击任何东西,看起来明智也似乎很好,并指示用户正在进行某些操作。

在.m文件

-(void)showAlertMethod 

{ 
    NSAutoreleasePool *pool1=[[NSAutoreleasePool alloc]init];   
progressAlert = [[UIAlertView alloc] initWithTitle:@"Uploading please wait...\n" message:@"" delegate:nil cancelButtonTitle:nil otherButtonTitles:nil]; 
    CGRect alertFrame = progressAlert.frame; 
    UIActivityIndicatorView* activityIndicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge]; 
    activityIndicator.frame = CGRectMake(135,alertFrame.size.height+55, alertFrame.size.width,30); 
    activityIndicator.hidden = NO; 
    activityIndicator.contentMode = UIViewContentModeCenter; 
    [activityIndicator startAnimating]; 
    [progressAlert addSubview:activityIndicator]; 
    [activityIndicator release]; 
    [progressAlert show]; 
    [pool1 release]; 

} 
-(void)dismissAlertMethod 
{ 
    NSAutoreleasePool *pool2=[[NSAutoreleasePool alloc]init]; 
    [progressAlert dismissWithClickedButtonIndex:0 animated:YES]; 
    [pool2 release]; 
} 

通话根据您的要求的方法.h文件中

UIAlertView *progressAlert; 

。 我以这种方式调用方法: -

[NSThread detachNewThreadSelector:@selector(showAlertMethod) toTarget:self withObject:nil]; 

[NSThread detachNewThreadSelector:@selector(dismissAlertMethod) toTarget:self withObject:nil]; 
+0

锁定屏幕的好方法,从来没有尝试过,但看起来很酷......我仍然怀疑锁定屏幕有多好,并且不让任何事情发生......再次,我在Neeta发布的代码中看到,首先显示alertView,然后将activityIndi​​cator添加到它,在那里我觉得可能是问题,但Neeta方面的一些细节代码可能有助于解决问题。 – 2011-05-09 05:58:17