2011-05-09 73 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