у меня есть сгруппированная таблица, и если я напишу:
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 7){
Он не нажимает на седьмую строку ...
У меня есть такой вид UITableView (сгруппированный):
- (void)viewDidLoad {
NSArray *arrTemp1 = [[NSArray alloc]
initWithObjects:@"Scuola/Università",@"Uscita con le amiche",@"Pranzo di lavoro",@"Lavoro",@"Appuntamento",@"All'ultimo momento",nil];
NSArray *arrTemp2 = [[NSArray alloc]
initWithObjects:@"Cena con amici",@"Cena di lavoro",@"Pub/Discoteca",@"Festa elegante",@"Appuntamento",@"All'ultimo momento",nil];
NSArray *arrTemp3 = [[NSArray alloc]
initWithObjects:@"Compleanno",@"Anniversario",@"Matrimonio",@"Laurea/Promozione",@"San Valentino",@"Natale/Capodanno",nil];
NSArray *arrTemp4 = [[NSArray alloc]
initWithObjects:@"Scelta e uso fondotinta",@"Scelta dei colori",@"I pennelli",@"Come sfumare",@"Contouring",@"Labbra perfette",nil];
NSDictionary *temp =[[NSDictionary alloc]
initWithObjectsAndKeys:arrTemp1,@"Trucco da giorno",arrTemp2,
@"Trucco da sera",arrTemp3,@"Eventi speciali",arrTemp4,@"Lezioni di base",nil];
self.tableContents =temp;
[temp release];
self.sortedKeys =[[self.tableContents allKeys]
sortedArrayUsingSelector:@selector(compare:)];
[arrTemp1 release];
[arrTemp2 release];
[arrTemp3 release];
[arrTemp4 release];
[super viewDidLoad];
}
Мне нужно что-то отличное от == 7?
Заранее спасибо
Весь код:
#import "TabellaController.h"
@implementation TabellaController
@synthesize tableContents;
@synthesize sortedKeys;
- (UITableViewCellAccessoryType)tableView:(UITableView *)tableView accessoryTypeForRowWithIndexPath:(NSIndexPath *)indexPath {
return UITableViewCellAccessoryDisclosureIndicator;
}
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
NSArray *arrTemp1 = [[NSArray alloc]
initWithObjects:@"Scuola/Università",@"Uscita con le amiche",@"Pranzo di lavoro",@"Lavoro",@"Appuntamento",@"All'ultimo momento",nil];
NSArray *arrTemp2 = [[NSArray alloc]
initWithObjects:@"Cena con amici",@"Cena di lavoro",@"Pub/Discoteca",@"Festa elegante",@"Appuntamento",@"All'ultimo momento",nil];
NSArray *arrTemp3 = [[NSArray alloc]
initWithObjects:@"Compleanno",@"Anniversario",@"Matrimonio",@"Laurea/Promozione",@"San Valentino",@"Natale/Capodanno",nil];
NSArray *arrTemp4 = [[NSArray alloc]
initWithObjects:@"Scelta e uso fondotinta",@"Scelta dei colori",@"I pennelli",@"Come sfumare",@"Contouring",@"Labbra perfette",nil];
NSDictionary *temp =[[NSDictionary alloc]
initWithObjectsAndKeys:arrTemp1,@"Trucco da giorno",arrTemp2,
@"Trucco da sera",arrTemp3,@"Eventi speciali",arrTemp4,@"Lezioni di base",nil];
self.tableContents =temp;
[temp release];
self.sortedKeys =[[self.tableContents allKeys]
sortedArrayUsingSelector:@selector(compare:)];
[arrTemp1 release];
[arrTemp2 release];
[arrTemp3 release];
[arrTemp4 release];
[super viewDidLoad];
}
- (void)dealloc {
[tableContents release];
[sortedKeys release];
[super dealloc];
}
#pragma mark Table Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return [self.sortedKeys count];
}
- (NSString *)tableView:(UITableView *)tableView
titleForHeaderInSection:(NSInteger)section
{
return [self.sortedKeys objectAtIndex:section];
}
- (NSInteger)tableView:(UITableView *)table
numberOfRowsInSection:(NSInteger)section {
NSArray *listData =[self.tableContents objectForKey:
[self.sortedKeys objectAtIndex:section]];
return [listData count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier";
NSArray *listData =[self.tableContents objectForKey:
[self.sortedKeys objectAtIndex:[indexPath section]]];
UITableViewCell * cell = [tableView
dequeueReusableCellWithIdentifier: SimpleTableIdentifier];
if (cell == nil){ cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero
reuseIdentifier:@"cellID"] autorelease];
}
//inseriamo nella cello l'elemento della lista corrispondente
cell.textLabel.text = [listData objectAtIndex:indexPath.row];
return cell;
}
// Metodo relativo alla selezione di una cella
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 6){
//l'utente ha cliccato sull'elemeno iPhone, quindi carichiamo la vista relativa
detail = [[ScuolaUniversitaController alloc] initWithNibName:@"ScuolaUniversita" bundle:[NSBundle mainBundle]];
}
//Facciamo visualizzare la vista con i dettagli
[self.navigationController pushViewController:detail animated:YES]; //rilasciamo il controller
[detail release];
detail = nil;
}
@end