2014-10-16 41 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 ")