테이블 프로그래밍 동안 :문제 난 그룹화 된 테이블이 있고, 내가 작성하는 경우
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (indexPath.row == 7){
그것은 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
그래, 나도 알아, 0부터 셀 수 있습니다.하지만 그것을 클릭 할 수 없습니다, 나는 6 개의 행마다 그룹화 된 테이블을 가지고 있기 때문에. – WinterIsComing
그래서 5 번보다 큰 indexPath.row를 삽입 할 때마다 ... 나는 그것을 클릭 할 수 없다 ... 왜 그런지 모르겠다. 단지 첫 번째 그룹화 된 셀이 작동하는 것 같다 .... 도움이된다 plz – WinterIsComing
나는 생각한다. 델리게이트 및 데이터 소스 메서드에 대한 코드를 제공해야합니다. – Ishu