2017-06-02 69 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

相關問題