2014-10-16 37 views
0

我有一个IPHone应用程序,其中我试图使用UITableViewRowAction编辑,复制和删除选项,它一直工作得很好。问题是我想使它与所有按钮具有相同的宽度并具有下划线标题。我这样做管理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]];` 

任何人都可以帮助我吗?

回答

3

以下是UIKit对于UITableViewRowAction中的接口。它看起来不像是一个大小。你可以自己做这一切,但这是非常耗时的:http://www.raywenderlich.com/62435/make-swipeable-table-view-cell-actions-without-going-nuts-scroll-views

我所做的只是为标题添加空格,直到按钮的尺寸相同(即@“___ Delete_____”)。

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

我知道它的怪异,但没有物业截至目前设定的行操作按钮的高度或宽度。 按钮的高度与行的高度相同。 按钮的宽度基于标题文本。 只有解决方法是在标题的两侧添加空白区域:

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