【发布时间】:2015-10-01 10:12:43
【问题描述】:
我在 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
【问题讨论】:
-
您好,请您粘贴您的代码
-
didSelectRowAtIndexPath 应该可以,检查你是否设置了你的委托。
-
我选择代表
标签: ios iphone xcode uitableview