我有一個名爲「同步」按鈕。當竊聽/把它壓將數據發送到網絡服務器和服務器(有什麼需要一段時間,並凍結GUI /按鈕)檢索答案讓我怎麼添加一個「請等待」和活動的指標,直到從服務器中的數據/答案到達並且文本/指示符被刪除並由來自服務器的回答取代?顯示活動指示器的動畫時,按下按鈕
此代碼凍結我的應用程序:
- (IBAction) syncButtonTapped
{
[syncButton setEnabled:NO];
//resultText.text= @"Bitte warten ...";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *docDir = [paths objectAtIndex: 0];
NSString *docFile = [docDir stringByAppendingPathComponent: @"deck.txt"];
NSString *post = [NSString stringWithContentsOfFile:docFile encoding:NSUTF8StringEncoding error:nil];
NSString *post2 = [post stringByReplacingOccurrencesOfString:@"\n" withString:@","];
NSString *post3 = [post2 stringByReplacingOccurrencesOfString:@"\r" withString:@""];
NSString *post4 = [NSString stringWithFormat:@"{\"results\":[%@]}",post3];
NSString *urlString = [NSString stringWithFormat:@"http://storecheck.cortona.de/fetchresults.php?results=%@",[post4 stringByAddingPercentEscapesUsingEncoding: NSASCIIStringEncoding]];
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
[request setURL:[NSURL URLWithString:urlString]];
[request setHTTPMethod:@"GET"];
NSString *data4 = @"";
[data4 writeToFile: docFile atomically: NO encoding: NSUTF8StringEncoding error:nil];
//send request & get response
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
}
我是一臺Mac Mini的工作與iOS 10.6.7
我還喜歡將黑色背景,0.5 alpha UIView放在一切之前,以使它們變暗並禁用任何與UI元素的用戶交互。 – bdares
輸入被禁用,所以不想這個,不需要這個,你的意思是 –
http://stackoverflow.com/questions/593234/how-to-use-activity-indicator-view-on-iphone – PJR