在UITableViewRowAction按钮中管理Equall宽度?

时间:2014-10-16 11:30:31

标签: ios iphone ipad ios8

我有一个IPHone应用程序,其中我试图使用UITableViewRowAction与编辑,复制和删除选项,它一直运作良好。问题是我想让它具有相同的宽度的所有按钮和带下划线的标题我正在这样做

`UITableViewRowAction *EditAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Edit” handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){

        indextodelete=(int)indexPath.section;
        // maybe show an action sheet with more options
           [self.mTableView setEditing:NO];
    }];
    EditAction.backgroundColor = [UIColor GreenColor]];`

有人能帮助我吗?

2 个答案:

答案 0 :(得分:3)

以下是 UITit UITableViewRowAction 的界面。它看起来没有大小。您可以自己完成所有操作,但这非常耗时:http://www.raywenderlich.com/62435/make-swipeable-table-view-cell-actions-without-going-nuts-scroll-views

我所做的只是在标题上添加空格,直到按钮看起来大小相同(即@" ___删除_____")。

NS_CLASS_AVAILABLE_IOS(8_0) @interface UITableViewRowAction : NSObject <NSCopying>

+ (instancetype)rowActionWithStyle:(UITableViewRowActionStyle)style title:(NSString *)title   handler:(void (^)(UITableViewRowAction *action, NSIndexPath *indexPath))handler;

@property (nonatomic, readonly) UITableViewRowActionStyle style;
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) UIColor *backgroundColor; // default background color is dependent on style
@property (nonatomic, copy) UIVisualEffect* backgroundEffect;

@end

答案 1 :(得分:1)

我知道它很奇怪但是现在没有属性来设置行动按钮的高度或宽度。 按钮的高度与行的高度相同。 按钮的宽度基于标题文本。 唯一的解决方法是在标题的两侧添加空白区域:

UITableViewRowAction(style: .Destructive, title: "  Delete  ")