私は情報をCMSにチェックする関数を呼び出すこの関数を持っています。 UIActivityIndicatorViewはチェックが完了するまでフリーズします。理由は分かりません。UIActivityIndicatorView freeze
EDIT:面白いことに、私はperformselectorをコメントアウトしました。 UIActivityIndicatorViewはまだフリーズしています。私は、それが回転し始めた私の背中のボタンをタップするまで....
を私はあなたが「重い」機能を少し遅らせ、アクティビティインジケータの火をさせなければならないストーリーボード、iOSの5
-(void)showLoading
{
[activity startAnimating];
//loading is a label to show "File Loading"
loading.alpha =1;
//is a label to show a 0.3 alpha of the label
blackOverlay.hidden =0;
[self performSelector:@selector(updateFromInternet:) withObject:@"a" afterDelay:2];
//[self updateFromInternet:@"a"];
}
-(void)updateFromInternet:(NSString *)urlStr
{
NSString *URLString = @"http://sites.google.com/site/iphonesdktutorials/xml/Books.xml";
NSURL *updateDataURL = [NSURL URLWithString:URLString];
NSMutableURLRequest *WPXMLFetchRequest = [NSMutableURLRequest requestWithURL:updateDataURL];
self.receivedData = [NSMutableData data];
self.updateConnection = [NSURLConnection connectionWithRequest:WPXMLFetchRequest delegate:self];
NSLog(@"Checking update at : %@", updateDataURL);
//[self.updateConnection cancel];
}
-(void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data
{
////NSlog(@"Receiving data");
[self.receivedData appendData:data];
}
-(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error
{
////NSlog(@"Failed to receive data");
self.receivedData = nil;
}
-(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response
{
////NSlog(@"Received response from data");
[self.receivedData setLength:0];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
NSString *data=[[NSString alloc]initWithData:self.receivedData encoding:NSUTF8StringEncoding];
NSLog(@"data %@",data);
NSError *parseError = nil;
//NSDictionary *xmlDict = [XMLReader dictionaryForXMLData:self.receivedData error:&parseError];
self.receivedDict = [XMLReader dictionaryForXMLData:self.receivedData error:&parseError];
[self showDataOnScrollView];
}
「アクティビティ」が開始してフリーズしたか、または固定されたままでしたか? – tipycalFlow
それが凍って、そこからupdateFromInternetが起動されたといいました。 – Desmond
バックグラウンドスレッドを参照しているコメントの意味は何ですか?メインスレッド以外から 'UIKit'オブジェクトを使用すべきではありません。ただし、スレッドコードは表示されていません。スレッドコードが他の場所にありますか、 'performSelector:withObject:afterDelay:をバックグラウンドスレッドとして参照していますか? – Jim