1
[self.tableview reloaddata] 전에 viewDidLoad() 함수에서 데이터로드 옵션을 추가하려고합니다. 추가하는 방법을 잘 모르겠습니다. 사용자에게 데이터로드가 있음을 알리는 방법이 있습니다. JSON 파일을 파싱하는 중입니다. 데이터가 3G에서 매우 느리게로드되므로 데이터를로드하는 옵션이로드된다는 것을 사용자가 알 수있는 더 좋은 방법입니다. 난 당신이 "로드 뷰"가 무슨 뜻인지 확실히 모르겠어요Loading tableview 데이터를 다시로드하기 전에 Loading View를 추가하는 방법이 있습니까?
- (void)viewDidLoad {
[super viewDidLoad];
// Add the view controller's view to the window and display.
responseData = [[NSMutableData data] retain];
self.twitterArray = [NSMutableArray array];
NSURLRequest *request = [NSURLRequest requestWithURL:
[NSURL URLWithString:@"http://search.twitter.com/search.json?q=mobtuts&rpp=5"]];
[[NSURLConnection alloc] initWithRequest:request delegate:self];
[super viewWillAppear:animated];
}
- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
[responseData setLength:0];
}
- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
[responseData appendData:data];
}
- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
[connection release];
NSString *responseString = [[NSString alloc] initWithData:responseData encoding:NSUTF8StringEncoding];
[responseData release];
NSDictionary *results = [responseString JSONValue];
self.twitterArray = [results objectForKey:@"results"];
[self.tableView reloadData]; // How to add loading view before this statement
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
// Return the number of rows in the section.
return [self.twitterArray count];
}