我的应用程序中有一个分组的表格视图,分为两部分:第一部分包含一行,第二部分包含5行。
UIButton *newBtn=[UIButton buttonWithType:UIButtonTypeCustom];
[newBtn setFrame:CGRectMake(5,10,35,30)];
[newBtn setImage:[UIImage imageNamed:@"icon.png"] forState:UIControlStateNormal];
[newBtn addTarget:self action:@selector(selector:) forControlEvents:UIControlEventTouchUpInside];
newBtn.tag=4;
[cell.contentView addSubview:newBtn];
Now in that selector methode i need to change it with another image.I am trying to do that in this way
UITableViewCell *cell=(UITableViewCell *)[sender superview];
NSIndexPath *path=[self.mtableview indexPathForCell:cell];
``但是瓶颈在某个时候。有人能将我指向怀特方向吗?
最佳答案
如果您只想更改按钮的图像,请将其添加到选择器中。
- (void)selector:(id)sender {
//some code
UIButton *button = (UIButton *)sender;
[button setImage:[UIImage imageNamed:@"newicon.png"] forState:UIControlStateNormal];
//some code
}
关于iphone - 单击某个特定单元格时,如何更改按钮?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13152435/