今天做項(xiàng)目遇到一個(gè)這樣的需求查排,記錄下來(lái),怕以后忘記!
需求是:點(diǎn)擊左邊這個(gè)自定義cell的區(qū)域跳轉(zhuǎn)到活動(dòng)詳情頁(yè)
看圖:
那么如果按照以前的點(diǎn)擊某行的cell- (void)tableView:(UITableView*)tableView didSelectRowAtIndexPath:(NSIndexPath*)indexPath{}
則不能實(shí)現(xiàn)需求提的功能秸滴,因?yàn)辄c(diǎn)擊的是整行。
接下來(lái)說(shuō)一下我的實(shí)現(xiàn)思路:做一個(gè)和點(diǎn)擊cell等大的button募判,在上點(diǎn)擊事件就好
//左邊的btn
//左邊的btn
@property(nonatomic,strong)UIButton*left_Btn;
- (void)viewDidLoad 創(chuàng)建button并添加點(diǎn)擊事件
_left_Btn= [[UIButtonalloc]initWithFrame:CGRectMake(0,30,KAppWidth-55,85)];
[_left_BtnaddTarget:self action:@selector(didJusp:)forControlEvents:UIControlEventTouchUpInside];
-(void)didJusp:(UIButton*)btn{
NSLog(@"------");
UIStoryboard*storyboard = [UIStoryboardstoryboardWithName:@"MainViewController"bundle:nil];
EventDetailsController*eventDetailsVC = [storyboardinstantiateViewControllerWithIdentifier:@"EventDetailsController"];
[self.navigationControllerpushViewController:eventDetailsVCanimated:YES];
}