Note that there are some explanatory texts on larger screens.

plurals
  1. POUITableView don't react on a tap
    text
    copied!<p>I have a fully working grouped tableview. But when i just tap on a cell - nothing happens. willSelectRowAtIndexPath is not even being called. All outlets are set correctly, userInteractions are enabled, tableView is the only view on a page. Googling for hours made no success. Everyone has a selection feature from the begining and someone even tries to ged rid of it. Help, please.</p> <p>Code (bad one, i know):</p> <pre><code>// // VKFriendsPage.m // vKontakte // // Created by ASPCartman on 3/29/10. // Copyright 2010 __MyCompanyName__. All rights reserved. // #import "VKFriendsPage.h" #import "UIImage+Resize.h" #import "VKProfilePage.h" @implementation VKFriendsPage @synthesize friends,onlineFriends,VKId,connection,avatarCache; -(void) didReceiveMemoryWarning { [super didReceiveMemoryWarning]; NSLog(@" Memary Wornenk!!! OLOLOLOLOL!"); } -(void)viewWillAppear:(BOOL)animated { table.backgroundColor=[UIColor clearColor]; if ([connection.myVkontakteID isEqual:VKId]) { friends=[connection.myVKProfile friendsAll]; onlineFriends=[connection.myVKProfile friendsOnline]; } self.avatarCache = [NSMutableDictionary dictionaryWithCapacity:2]; queue = [NSOperationQueue new]; table.allowsSelection=YES; } #pragma mark Table Data Source Protocol Implementation //Количество строк в секции //0ая - Ребята онлайн //1ая - Все - (NSInteger)tableView:(UITableView *)table numberOfRowsInSection:(NSInteger)section { if (section==0) { return [onlineFriends count]; }else if (section==1) { return [friends count]; }else { return 0; } } //Создание клеток - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { //Инит клетки UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"FriendCell"]; //Выбор секции NSArray *currentMan; if (indexPath.section==0) { currentMan=[onlineFriends objectAtIndex:indexPath.row]; }else if (indexPath.section==1) { currentMan=[friends objectAtIndex:indexPath.row]; }else { currentMan=nil; } cell.selectionStyle=UITableViewCellSelectionStyleBlue; cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator; cell.textLabel.text=[currentMan objectAtIndex:1]; cell.detailTextLabel.text=@"TODO: Статусы..."; if ([avatarCache objectForKey:[currentMan objectAtIndex:2]]==nil) { NSDictionary *dic = [NSDictionary dictionaryWithObjectsAndKeys:indexPath,@"Path",[currentMan objectAtIndex:2],@"URLString",nil]; NSInvocationOperation *operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(fetchAvatar:) object:dic]; [cell.imageView setImage:[UIImage imageWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"profileIco" ofType:@"jpg"]]]; [queue addOperation:operation]; [operation autorelease]; }else { [cell.imageView setImage:[avatarCache objectForKey:[currentMan objectAtIndex:2]]]; } return [cell autorelease]; } - (NSIndexPath *)tableView:(UITableView *)tableView willSelectRowAtIndexPath:(NSIndexPath *)indexPath { return indexPath; } - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { VKProfilePage *profilePage=[[VKProfilePage alloc] init]; profilePage.title=[tableView cellForRowAtIndexPath:indexPath].textLabel.text; profilePage.connection=connection; NSString *VKID; if (indexPath.section==0) { VKID=[[onlineFriends objectAtIndex:indexPath.row] objectAtIndex:0]; }else if (indexPath.section==1) { VKID=[[friends objectAtIndex:indexPath.row] objectAtIndex:0]; } profilePage.profile=[connection getProfileOf:VKID]; [self.navigationController pushViewController:profilePage animated:YES]; [profilePage release]; } -(void)fetchAvatar:(NSDictionary *)dic { NSData *imageData=[NSData dataWithContentsOfURL:[NSURL URLWithString:[dic objectForKey:@"URLString"]]]; UIImage *image=[UIImage imageWithData:imageData]; UIImage *resizedImage = [image thumbnailImage:70 transparentBorder:0 cornerRadius:5 interpolationQuality:kCGInterpolationHigh]; [avatarCache setObject:resizedImage forKey:[dic objectForKey:@"URLString"]]; [self performSelectorOnMainThread:@selector(updateRow:) withObject:[dic objectForKey:@"Path"] waitUntilDone:NO]; } -(void)updateRow:(NSIndexPath *) ip { [table reloadRowsAtIndexPaths:[NSArray arrayWithObject:ip] withRowAnimation:UITableViewRowAnimationNone]; } - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { return 2; } - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath; { return NO; }; - (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if (section==0) { return @"Online"; }else { return @"Offline"; } } - (NSString *)tableView:(UITableView *)tableView titleForFooterInSection:(NSInteger)section { return nil; }; @end </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload