2014-11-20 2 views
0

Я хочу отобразить таблицу с высоким рейтингом, именем пользователя и рисунком профиля facebook для друзей пользователей, играющих в игру с использованием UITableView. У меня есть одноэлементный класс facebook, который я использую для управления всем кодом facebook. При попытке доступа к таблице я продолжаю получать следующую ошибку. Бревно:Непризнанная проблема выбора при отображении рекордов facebook в виде таблицы

-[FacebookManager tableView:didSelectRowAtIndexPath:]: unrecognized selector sent to instance 0x16f1d790 
2014-11-14 14:24:43.000 MyApp[2964:938911] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FacebookManager tableView:didSelectRowAtIndexPath:]: unrecognized selector sent to instance 0x16f1d790' 
*** First throw call stack: 
(0x29a9ec1f 0x37249c8b 0x29aa4039 0x29aa1def 0x299d3df8 0x1b00a9 0x1328a3 0x13224d 0x132d35 0xc7c73  0x11d555 0x11dec7 0xf132d 0x2cf8e317 0x2cf87be1 0x2cf5e3dd 0x2d1d1c29 0x2cf5ce39 0x29a65377 0x29a64787 0x29a62ded 0x299b1211 0x299b1023 0x30daa0a9 0x2cfbd1d1 0x167353 0x86c90) 
libc++abi.dylib: terminating with uncaught exception of type NSException 

См. Соответствующий код ниже. метод, который обрабатывает отображение таблицы (которая находится в другом классе):

-(void)scoresAndMore { 

NSIndexPath *indexPath = [NSIndexPath indexPathForRow:1 inSection:0]; 
[[FacebookManager sharedFacebookManager].myTableView selectRowAtIndexPath:indexPath animated:YES scrollPosition:UITableViewScrollPositionNone]; 
[[FacebookManager sharedFacebookManager] tableView:[FacebookManager sharedFacebookManager].myTableView didSelectRowAtIndexPath:indexPath]; 

} 

Код таблицы в классе FacebookManager:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 

UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"cell"]; 


[FBRequestConnection startWithGraphPath:[NSString stringWithFormat:@"%llu/scores?fields=score,user", kuFBAppID] parameters:nil HTTPMethod:@"GET" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) { 

    if (result && !error) 
    { 
     for (NSDictionary *dict in [result objectForKey:@"data"]) 
     { 
      NSString *name = [[dict objectForKey:@"user"] objectForKey:@"name"]; 
      NSString *strScore = [dict objectForKey:@"score"]; 
      NSString *profilePictureID = [[dict objectForKey:@"user"] objectForKey:@"id"]; 
      NSString *profilePicture = [NSString stringWithFormat:@"%@/picture?width=80&height=80&redirect=false",profilePictureID]; 
      NSString *url = [[NSString alloc] initWithFormat:@"https://graph.facebook.com/%@/picture",profilePictureID]; 
      UIImage *image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:url]]]; 
      NSLog(@"The URL is %@. The image URL is %@", url, image); 
      NSLog(@"This message is in the UITableViewCell and will hopefully show the name %@ and the score %@ along with %@ as the profile picture URL.", name, strScore, profilePicture); 

      // DID NOT WORK - cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", image]]; 
      // DID NOT WORK - cell.imageView.image = [UIImage imageNamed:[NSString stringWithFormat:@"%@", profilePicturel]]; 

      cell.imageView.image = image;//[UIImage imageNamed:[NSString stringWithFormat:@"%@", url]]; 

      cell.textLabel.text = [NSString stringWithFormat:@"%@", name]; 
      cell.detailTextLabel.text = [NSString stringWithFormat:@"Score: %@", strScore]; 

     } 
    } 

}]; 

return cell; 
} 

в инициализации класса одноэлементного FacebookManager

self.myTableView.delegate = self; 

Как решить эту проблему?

ответ

0

Ну вы, кажется, называть [tableView:didSelectRowAtIndexPath:] по своему менеджеру facebook на этой линии

[[FacebookManager sharedFacebookManager] tableView:[FacebookManager sharedFacebookManager].myTableView didSelectRowAtIndexPath:indexPath]; 

Ваш менеджер facebook делегат вашего UITableView Убеждайтесь ваш менеджер facebook реализует этот метод.

- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:indexPath { 
} 
Смежные вопросы