嗨我的問題是,我從Web服務獲取響應,當我解析它並添加到表並重新加載表視圖它不刷新。雖然如果我在鍵盤上調用[table reload],它會在那裏得到更新。有人能告訴我,如果我在想念什麼如何表接收響應時重新加載ios數據
這就是我要做的
- (void) longPoll {
//create an autorelease pool for the thread
@autoreleasepool {
NSLog(@"polling");
VSAppDelegate *var = (VSAppDelegate*)[[UIApplication sharedApplication] delegate];
//compose the request
NSError* error = nil;
NSHTTPURLResponse* response = nil;
//send the request (will block until a response comes back)
NSData* responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];
NSLog(@"polling response is %d",response.statusCode);
//pass the response on to the handler (can also check for errors here, if you want)
[self performSelectorOnMainThread:@selector(dataReceived:) withObject:responseData waitUntilDone:YES];
}
[self performSelectorInBackground:@selector(longPoll) withObject: nil];
}
- (void) startPoll {
[self performSelectorInBackground:@selector(longPoll) withObject: nil];
}
- (void) dataReceived: (NSData*) theData
{
//process the response here
NSError *error = nil;
NSLog(@"polling data is %@",[[NSString alloc] initWithData:theData encoding:NSUTF8StringEncoding]);
NSLog(@"polling data is %@",[[theData base64EncodedString]base64DecodedString]);
NSDictionary *notifDic= [NSJSONSerialization JSONObjectWithData:theData options:kNilOptions error:&error];
//VSViewControllerSplit *split = [[VSViewControllerSplit alloc]init];
[self RecieveFunction:notifDic];
}
你是否檢查過你的數據源是否有正確的數據,並且它是否正確鏈接到你的tableview? – user1781290
是的,這是正確的問題是我把它添加到表中,然後調用它,但沒有任何反應。是的,表格視圖不是零,因爲我能夠在我調試代碼時看到它。此外,當我點擊文本字段它去鍵盤確實顯示通知,即時通訊調用[表重新加載數據],並有它得到重新加載 – BackStabber
後ur代碼你先試過什麼,那麼只有我們能夠找到問題 – CoolMonster