我正在使用 CustomCells 填充 UITableView,并且正在尝试调用 didSelectRowAtIndexPath。这是自定义单元格的标题。
#import <UIKit/UIKit.h>
@interface CustomCell : UITableViewCell {
IBOutlet UILabel *bizNameLabel;
IBOutlet UILabel *addressLabel;
IBOutlet UILabel *mileageLabel;
IBOutlet UIImageView *bizImage;
}
@property (nonatomic, retain) UILabel *bizNameLabel;
@property (nonatomic, retain) UILabel *addressLabel;
@property (nonatomic, retain) UILabel *mileageLabel;
@property (nonatomic, retain) UIImageView *bizImage;
@end
非常简单明了。我有一个 detailDisclosureButton,我也在单元格的 cellForRowAtIndexPath 方法中添加到单元格中,并且accessoryButtonTappedForRowWithIndexPath:
正在调用该方法,但 didSelectRowAtIndexPath 不是。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"CustomCell";
CustomCell *cell = (CustomCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"CustomCellView"
owner:self options:nil];
#ifdef __IPHONE_2_1
cell = (CustomCell *)[nib objectAtIndex:0];
#else
cell = (CustomCell *)[nib objectAtIndex:1];
#endif
}
// Configure the cell.
NSDictionary *dict = [rows objectAtIndex: indexPath.row];
/*
CODE TO POPULATE INFORMATION IN CUSTOM CELLS HERE
*/
#ifdef __IPHONE_3_0
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
#endif
return cell;
}
我在所有方法和断点中都放了一个 NSLog。我试图调用的方法不是,但在我的 CustomCell 类中,以下方法是。那么有没有办法让 didSelectRowAtIndexPath 在使用 CustomCell 时被调用?
- (void)setSelected:(BOOL)selected animated:(BOOL)animated