iphone - didSelectRowAtIndexPath: wywoływany tylko po długim naciśnięciu na komórkę użytkownika
Tworzę jedną aplikację opartą na widoku tabeli. Stworzyłem niestandardową komórkę tabeli dla tabeli, która zawiera 2 etykiety, 1 obraz i 1 przycisk. Metoda źródła danych widoku tabeli działa poprawnie. Korzystam z xib zarówno dla niestandardowej klasy komórki, jak i kontrolera widoku, i łączę delegata i źródło danych z właścicielem pliku. Ale problem polega na tym, że kiedy wybieram wiersz tabeli, didSelectRowAtIndexPath nie pali się. Jak wspomniano, jedynym sposobem na odpalenie jest przytrzymanie celi przez około 3-4 sekundy. Czy ktoś ma jakiś pomysł, dlaczego tak się dzieje?
Dzięki za wszelkie wskazówki ...
Oto moje metody widoku tabeli ..
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [finalAddonsArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
NewCustomCell *cell = (NewCustomCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
NSArray *nib=[[NSBundle mainBundle]loadNibNamed:@"NewCustomCell" owner:self options:nil];
cell=[nib objectAtIndex:0];
}
Addons *addons1=[[Addons alloc]init];
addons1= [finalAddonsArray objectAtIndex:indexPath.row];
if (addons1.data == nil) {
cell.ivCategory.image = [UIImage imageNamed:@"blogo.jpg"];
}
else
{
cell.ivCategory.image=[UIImage imageWithData:addons1.data];
}
cell.lblTitle.text = addons1.name;
if (addons1.price == nil) {
cell.lblPrice.text = nil;
}
else{
cell.lblPrice.text = [NSString stringWithFormat:@"%@ rs",addons1.price];
}
[cell.button addTarget:self
action:@selector(editButtonPressed:)
forControlEvents:UIControlEventTouchUpInside];
cell.button.tag=indexPath.row;
index = indexPath;
cell.selectionStyle = UITableViewCellSelectionStyleGray;
return cell;
}
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"sjcjksbcjksbcfkebscf1234567890");
}
Jeszcze jedna rzecz, którą dostaję, że jeśli używam domyślnego UITableViewCell zamiast niestandardowej komórki, to mój problem jest taki sam, metoda delegowania nie powoduje pożaru.
Własne właściwości komórki: