我在iOS&中使用过原型单元格。我添加了一张图片&细胞上的标签。这就是我能够显示图像的方法。单元格上的文字。但由于这个原因,我无法选择整行和didrowselect的委托方法不起作用。请告诉解决方案?
表格视图委托代码
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
NSLog(@"delegate called");
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
NSLog(@"row in section called");
return[arr_userAlbums count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"tableCell";
AlbumCell *cell = [self.tableView
dequeueReusableCellWithIdentifier:CellIdentifier
forIndexPath:indexPath];
UserAlbum *user_allbum=[arr_userAlbums objectAtIndex:indexPath.row];
cell.cell_label.text=user_allbum.album_name;
cell.cell_img.image = [UIImage imageNamed:@"more.png"];
[cell.cell_img setImageWithURL:[NSURL URLWithString:[IMAGE_BASE_URL stringByAppendingString:user_allbum.album_image]]];
cell.accessoryType = UITableViewCellAccessoryCheckmark;
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"row event occured");
}
AlbumCell.h
#import <UIKit/UIKit.h>
@interface AlbumCell : UITableViewCell
@property (weak, nonatomic) IBOutlet UIImageView *cell_img;
@property (weak, nonatomic) IBOutlet UILabel *cell_label;
@end
答案 0 :(得分:0)
确认您已触及视图
-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
{
NSLog(@"touch at %@", touch.view);
if ([NSStringFromClass([touch.view class]) isEqualToString:@"UITableViewCellContentView"])
return NO;
else
return YES;
}