相关疑难解决方法(0)

标题的UITableViewRowAction图像

我做了一个自定义的UITableViewRowAction.现在我想添加一个图像而不是文本.我知道这是可能的,但不知道该怎么做.你们中的某些人是否知道如何在Swift中做到这一点并想帮助我?谢谢你的回答!

uitableview ios swift xcode6 uitableviewrowaction

30
推荐指数
3
解决办法
3万
查看次数

UITableViewRowAction标题为图像图标而不是文本

我想在Swift中的tableviewCell中的滑动操作中放置图标(图像)而不是文本.

但我不知道如何把图像而不是标题文字?

我的代码如下:

func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject]?  {

    var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share" , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in
        // 2
        let shareMenu = UIAlertController(title: nil, message: "Share using", preferredStyle: .ActionSheet)

        let twitterAction = UIAlertAction(title: "Twitter", style: UIAlertActionStyle.Default, handler: nil)
        let cancelAction = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil)

        shareMenu.addAction(twitterAction)
        shareMenu.addAction(cancelAction)


        self.presentViewController(shareMenu, animated: true, completion: nil)
    })
    // 3
    var rateAction =    (style: UITableViewRowActionStyle.Default, title: "rate",im , handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> …
Run Code Online (Sandbox Code Playgroud)

uitableview ios swift

29
推荐指数
3
解决办法
3万
查看次数

如何在Table View中将图像添加到行动作?

从右侧滑动单元格时如何添加自定义图像以删除按钮UITableview,如下图所示?

在此输入图像描述

 func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [UITableViewRowAction]? {

    let remove = UITableViewRowAction(style: .Default, title: "\nRemove") { action, indexPath in }
    remove.backgroundColor = UIColor(patternImage: UIImage(named: "remove")!) }
Run Code Online (Sandbox Code Playgroud)

从上面的代码中可以看到Image,但它显示为堆叠在一起的一组图像.我的意思是,我无法设置"ContentMode"".ScaleToAspectFit""UIImage"

这种方法的最佳方法是什么?

示例代码可能很明显.

tableview ios swift uitableviewrowaction

12
推荐指数
3
解决办法
9187
查看次数

iOS 8 UITableViewRowAction:向左滑动,图像?

我刚刚在iOS8上遇到过这个新的API.但是,如果可以使用图像而不是文本并允许左右滑动,我无法找到任何解决方案?这甚至可能吗?我发现的唯一实现是:

- (NSArray *)tableView:(UITableView *)tableView editActionsForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewRowAction *moreAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Button1" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
        // maybe show an action sheet with more options
        [self.tableView setEditing:NO];
    }];
    moreAction.backgroundColor = [UIColor blueColor];

    UITableViewRowAction *moreAction2 = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleNormal title:@"Button2" handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
        [self.tableView setEditing:NO];
    }];
    moreAction2.backgroundColor = [UIColor blueColor];

    UITableViewRowAction *deleteAction = [UITableViewRowAction rowActionWithStyle:UITableViewRowActionStyleDestructive title:@"Delete"  handler:^(UITableViewRowAction *action, NSIndexPath *indexPath){
        [self.tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
    }];

    return @[deleteAction, moreAction, moreAction2];
}
Run Code Online (Sandbox Code Playgroud)

objective-c uitableview ios

9
推荐指数
2
解决办法
1万
查看次数

UITableViewRowAction与图像而不是标题

cell想像邮件应用程序一样进行滑动操作.

在此输入图像描述

我设置UIImagebackgroundColor行动作.

 action.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"remove"]];
Run Code Online (Sandbox Code Playgroud)

但我在背景上并排重复我的图像.像这样. 在此输入图像描述

图像尺寸有问题吗?可以告诉我如何解决它,或另一种方法来做到这一点?

objective-c ios uitableviewrowaction

7
推荐指数
1
解决办法
4705
查看次数