2017-06-02 41 views

回答

0

我明白你的问题,我得到了解决方案。

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *strId = @"cell"; 
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:strId]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strId]; 
    } 
    UIButton *butArrow = [UIButton buttonWithType:UIButtonTypeRoundedRect]; 
    butArrow.frame = CGRectMake(200, 20, 100, 25);; 
    [butArrow setTitle:@"Arrow" forState:UIControlStateNormal]; 
    butArrow.tag = indexPath.row; 
    [butArrow addTarget:self action:@selector(actionNavigate:) forControlEvents:UIControlEventTouchUpInside]; 
    [cell.contentView addSubview:butArrow]; 
    return cell; 
} 

//Button Action method 
-(void)actionNavigate:(UIButton*)sender 
{ 
    if (sender.tag == 0) //Your particular or specific button tag 
    { 
    //Here Write the code for Navigating to next view controller 
    } 
} 
+0

或者:'cell.accessoryView = butArrow' – Koen

+0

是的,但我给运算非常样品。 – user3182143

相关问题