У меня проблема с индикатором UIActivity, я реализую индикатор активности на UITableView Cell, но он не работает. Мой код выглядит следующим образом: если его можно решить, пожалуйста, скажите мне ошибку, которую я делаю в этом.UIActivityIndicator on UITableViewCell не работает?
- (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];
}
Thanks in Advance ..!
удалите следующие из кода [таблица reloadData]; [индикаторная остановка]; показывает индикатор при их удалении? –
Вы пробовали использовать '[self performSelectorOnMainThread: @selector (startAnimating :) withObject: indicator waitUntilDone: NO];'? – Mat
Да, я также пробовал это, но проблема в том, что я не могу отправить в него несколько параметров. – Warewolf