【发布时间】:2014-04-07 12:23:36
【问题描述】:
由于我在我的应用程序中使用滑出式菜单控制器 - 在 UITablewViewCell 上滑动删除不再起作用,因为平移手势用于打开/关闭侧菜单。
所以,我正在考虑添加一个删除按钮以始终显示在每个单元格上 - 因此用户只需点击删除即可删除该单元格。
我将此代码添加到 UItableView cellforRowAtIndexPath 方法:
/* Remove Button */
UIButton *removeButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
removeButton.frame = CGRectMake(200.0f, 5.0f, 75.0f, 30.0f);
[removeButton setTitle:@"Remove" forState:UIControlStateNormal];
removeButton.tintColor = [UIColor colorWithRed:0.667 green:0.667 blue:0.667 alpha:1]; /*#aaaaaa*/
removeButton.titleLabel.font = [UIFont systemFontOfSize:15];
[cell addSubview:removeButton];
[removeButton addTarget:self
action:@selector(removeItem:)
forControlEvents:UIControlEventTouchUpInside];
这会添加按钮,并且在删除方法中我不确定如何实际删除正确的单元格。
任何人都可以在这里指出正确的方向吗?
谢谢!
【问题讨论】:
标签: ios objective-c uitableview