UIActivityインジケーターに関して問題があります。UITableViewセルにアクティビティインジケーターを実装していますが、機能していません。私のコードは次のとおりです。解決できる場合は、私が行っている間違いを教えてください。
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UIActivityIndicatorView *indicator=[[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];
if (segmentControl.selectedSegmentIndex==0)
{
if ([indexPath row]==[FriendSuggestion count])
{
int cursor=[Constants getCursorForKey:@"friendList_cursor"];
if (cursor!=0)
{
[[tableView cellForRowAtIndexPath:indexPath] addSubview:indicator];
[indicator setFrame:CGRectMake(40, 25, 37, 37)];
[NSThread detachNewThreadSelector:@selector(startAnimating) toTarget:indicator withObject:nil];
dispatch_async(dispatch_get_main_queue(), ^{
[self loadingMore:indexPath :indicator :cursor];
});
}else
isNoMoreData=YES;
[tableView reloadData];
}
}
else
{
if ([indexPath row]==[popularSuggestion count])
{
int cursor=[Constants getCursorForKey:@"popularList_cursor"];
if (cursor!=0)
{
[[tableView cellForRowAtIndexPath:indexPath] addSubview:indicator];
[indicator setFrame:CGRectMake(40, 25, 37, 37)];
[NSThread detachNewThreadSelector:@selector(startAnimating) toTarget:indicator withObject:nil];
dispatch_async(dispatch_get_main_queue(), ^{
[self loadingMore:indexPath :indicator :cursor];
});
}else
isNoMoreData=YES;
[tableView reloadData];
}
}
}
-(void)loadingMore:(NSIndexPath*)indexPath:(UIActivityIndicatorView*)indicator:(int)cursor
{
NSLog(@"loading more called ...");
if (segmentControl.selectedSegmentIndex==0)
{
isNoMoreData=NO;
NSArray *nextArray=[[NSArray alloc] init];
nextArray=[Constants getFriendsSuggestionsStr:cursor];
for (NSDictionary *dic in nextArray) {
[FriendSuggestion addObject:dic];
}
}else
{
isNoMoreData=NO;
NSArray *nextArray=[[NSArray alloc] init];
nextArray=[Constants getPopularSuggestionsStr:cursor];
for (NSDictionary *dic in nextArray) {
[popularSuggestion addObject:dic];
}
}
[table reloadData];
[indicator stopAnimating];
}
前もって感謝します..!