相关疑难解决方法(0)

UITableViewCell定制配件 - 获取一排配件

我有一个很大的问题.我正在尝试在每个UITableViewCell中创建一个最喜欢的按钮UITableView.这非常有效,我现在按下时会执行一个动作和选择器.

accessory = [UIButton buttonWithType:UIButtonTypeCustom];
[accessory setImage:[UIImage imageNamed:@"star.png"] forState:UIControlStateNormal];
accessory.frame = CGRectMake(0, 0, 15, 15);
accessory.userInteractionEnabled = YES;
[accessory addTarget:self action:@selector(didTapStar) forControlEvents:UIControlEventTouchUpInside];
cell.accessoryView = accessory;
Run Code Online (Sandbox Code Playgroud)

和选择器:

- (void) didTapStar {
    UITableViewCell *newCell = [tableView cellForRowAtIndexPath:/* indexPath? */];

    accessory = [UIButton buttonWithType:UIButtonTypeCustom];
    [accessory setImage:[UIImage imageNamed:@"stared.png"] forState:UIControlStateNormal];
    accessory.frame = CGRectMake(0, 0, 26, 26);
    accessory.userInteractionEnabled = YES;
    [accessory addTarget:self action:@selector(didTapStar) forControlEvents:UIControlEventTouchDown];
    newCell.accessoryView = accessory;
}
Run Code Online (Sandbox Code Playgroud)

现在,问题在于:我想知道按下的配件属于哪一行.我怎样才能做到这一点?

谢谢 :)

iphone row accessory uitableview ios4

14
推荐指数
2
解决办法
1万
查看次数

如何在UITableView上不使用自定义单元格的情况下添加按钮?

如何在a上添加自定义按钮UITableViewCell,然后使用该按钮删除单元格而不使用Interface Builder和Custom Cell?

iphone cocoa-touch uitableview

2
推荐指数
1
解决办法
9341
查看次数

标签 统计

iphone ×2

uitableview ×2

accessory ×1

cocoa-touch ×1

ios4 ×1

row ×1