Я создал настраиваемую ячейку tableView и вижу свой tableView с нужной настраиваемой ячейкой.Теперь проблема в том, что я не могу выбрать строку таблицы.Я пытался отобразить вывод консоли изнутри - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
, но он никогда не вызывался.Я сбит с толку.Я не знаю, что я делаю не так.Ниже приведен мой индивидуальный класс ячейки:
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString *)reuseIdentifier {
if (self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) {
// Initialization code
CGRect contentRect = self.contentView.bounds;
CGFloat boundsX = contentRect.origin.x;
_title = [[UILabel alloc]initWithFrame:CGRectMake(boundsX +70, 5, 100, 25)];
_title.textAlignment = UITextAlignmentLeft;
_title.font = [UIFont systemFontOfSize:14];
_details = [[UILabel alloc]initWithFrame:CGRectMake(boundsX + 70, 30, 100, 15)];
_details.textAlignment = UITextAlignmentLeft;
_details.font = [UIFont systemFontOfSize:10];
_duration = [[UILabel alloc] initWithFrame:CGRectMake(boundsX + 200, 10, 65, 15)];
_duration.textAlignment = UITextAlignmentRight;
_duration.font = [UIFont systemFontOfSize:10];
_price = [[UILabel alloc]initWithFrame:CGRectMake(boundsX + 180, 30, 80, 15)];
_price.textAlignment = UITextAlignmentRight;
_price.font = [UIFont systemFontOfSize:10];
_listingImage = [[UIImageView alloc]initWithFrame:CGRectMake(boundsX +10, 0, 50, 50)];
[self.contentView addSubview:_title];
[self.contentView addSubview:_details];
[self.contentView addSubview:_price];
[self.contentView addSubview:_duration];
[self.contentView addSubview:_listingImage];
[_title release];
[_details release];
[_duration release];
[_price release];
[_listingImage release];
}
return self;
}
Ниже приведена моя tableView: cellForRowAtIndexPath:
функция:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
CustomizedCell *cell = (CustomizedCell *) [self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
cell = [[[CustomizedCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
// cell = [[[CustomizedCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:CellIdentifier] autorelease];
}
ADJListing *listing = [self.dataSource.listings objectAtIndex:indexPath.row];
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell._title.text = listing.title;
cell._details.text = listing.details;
cell._price.text = [listing.price stringValue];
cell._duration.text = (NSString*) listing.start_datetime;
cell._listingImage.image = [UIImage imageNamed:@"picture.png"];
return cell;
}
Опять же, это мой tableView:didSelectRowAtIndexPath:
метод
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
// [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
NSLog(@"data");
detailedVC = [[DetailedViewController alloc] init];
detailedVC.dataSource = self.dataSource;
[self.navigationController pushViewController:detailedVC animated:YES];
[detailedVC release];
}
Любая помощь будет оценена.
Спасибо Вик