2015-10-01 57 views
0

我在iOS中使用了原型單元格&我在單元格上添加了圖像&標籤。這是我能夠在單元格上顯示圖像&文字的方式。但由於這我無法選擇整行& didrowselect的委託方法不起作用。請告訴解決方案?如何檢測在iOS中自定義表格視圖的行?

碼錶視圖代表

- (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

你好,請你能粘貼代碼 – Masterfego

+1

didSelectRowA tIndexPath應該工作,檢查你是否設置了你的委託。 –

+0

我選擇代表 – TechGuy

回答

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; 
} 
相關問題