【发布时间】:2013-06-13 19:33:25
【问题描述】:
我有两个完全相同的问题 1)我在一个调用 IBAction 的单元格中有一个 UIButton :
- (IBAction)deleteFriend:(id)sender
{
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self->table];
NSIndexPath *indexPath = [self->table indexPathForRowAtPoint:buttonPosition];
if (indexPath != nil)
{
UITableViewCell *cell = [self->table cellForRowAtIndexPath:indexPath];
[UIView animateWithDuration:0.3 animations:^{
cell.alpha = 0;
} completion: ^(BOOL finished) {
cell.hidden = YES;
button.hidden = YES;
}];
}
所以基本上我想在 IBAction 之前确认警报,但这是问题所在。我不知道如何将发件人传递给 UIAlertView 的 buttonIndex 以便它可以完成这个 IBAction 的工作
2) 在代码中,我告诉单元格(IBAction 中的单元格)隐藏,还有我在 cellforRowatIndexPath 中定义的按钮:
button = [UIButton buttonWithType:UIButtonTypeCustom];
[button setBackgroundImage:buttonImage forState:UIControlStateNormal];
button.frame = CGRectMake(272.0f, 15.0f, 30.0f, 30.0f);
[cell button];
[button addTarget:self action:@selector(deleteFriend:)
forControlEvents:UIControlEventTouchUpInside];
但不知何故,它会随机隐藏其他单元格中的其他按钮。为什么它不只是隐藏在一个单元格中?
提前致谢!
【问题讨论】:
-
我想帮助你,但我无法理解你的问题的描述。是这两个问题吗?第二期的单元格是什么?尽量说得更清楚。
-
有两个问题:第一个是发件人定义的单元格,而在后者中,我只是在 cellForRowAtIndexPath 中定义了按钮,但我在上面的 IBAction 中隐藏了这个按钮
-
您是否有理由不能以编程方式使用单元格的索引并仅操作该单元格中的按钮?
-
因为我通过单击按钮启动操作,该按钮启动 ibaction,我没有在方法中声明单元格
-
您的问题很难理解。你想在按下按钮时弹出一个 alertView 吗?
标签: ios uitableview ibaction sender