Wiem, że wspomniana kwestia została wcześniej wspomniana, ale rezolucje tam nie miały zastosowania. Mam UINavigationController z wbudowanym UITableViewController skonfigurować przy użyciu IB. W IB delegat UITableView i dataSource są ustawione na moją pochodną UITableViewController. Ta klasa została dodana przy użyciu szablonów XCode dla klas UITableViewController. Nie ma niestandardowej opcji UITableViewCell, a widok tabeli używa domyślnego zwykłego stylu tylko z jednym tytułem.iPhone: didSelectRowAtIndexPath nie wywołano
Cóż, w symulatorze lista jest renderowana poprawnie, z dwoma elementami dostarczonymi przez dataSource, więc źródło danych jest poprawnie połączone. Jeśli usunę łącze wyjściowe dla źródła danych w IB, zamiast niego zostanie wyświetlona pusta tabela.
Zaraz po dotknięciu jednego z tych dwóch elementów miga na niebiesko, a GDB napotyka przerwę w numerze __forwarding__
w zakresie UITableView::_selectRowAtIndexPath
. Nie osiąga punktu przerwania w mojej niepustej metodzie didSelectRowIndexPath. Sprawdziłem argumenty i nazwę metody, aby wykluczyć literówki powodujące inny selektor.
Niedawno nie udało mi się ustalić, czy delegat jest ustawiony prawidłowo, ale ponieważ jest ustawiony równorzędnie ze źródłem danych, który pobiera dwa elementy z tej samej klasy, oczekuję, że zostanie poprawnie ustawiony. Co jest nie tak?
Używam iPhone'a/iPada SDK 3.1.2 ... ale wypróbowałem także z iPhone SDK 3.1 w symulatorze.
EDIT: Jest to kod mojego UITableViewController wyprowadzeniu:
#import "LocalBrowserListController.h"
#import "InstrumentDescriptor.h"
@implementation LocalBrowserListController
- (void)viewDidLoad {
[super viewDidLoad];
[self listLocalInstruments];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
}
- (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
}
- (void)viewDidUnload {
[super viewDidUnload];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [entries count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
if (([entries count] > 0) && ([indexPath length] > 0))
cell.textLabel.text = [[[entries objectAtIndex:[indexPath indexAtPosition:[indexPath length] - 1]] label] retain];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (([entries count] > 0) && ([indexPath length] > 0))
{
...
}
}
- (void)dealloc {
[super dealloc];
}
- (void) listLocalInstruments {
NSMutableArray *result = [NSMutableArray arrayWithCapacity:10];
[result addObject:[InstrumentDescriptor descriptorOn:[[NSBundle mainBundle] pathForResource:@"example" ofType:@"idl"] withLabel:@"Default 1"]];
[result addObject:[InstrumentDescriptor descriptorOn:[[NSBundle mainBundle] pathForResource:@"example" ofType:@"xml"] withLabel:@"Default 2"]];
[entries release];
entries = [[NSArray alloc] initWithArray:result];
}
@end
Możliwy duplikat [Wybierz wiersz widoku tabeli programowo] (http://stackoverflow.com/questions/2035061/select-tableview-row-programmically) – jk2K