swift – editActionsForRowAtIndexPath不能在iOS 8上使用Xcode 7执行

swift – editActionsForRowAtIndexPath不能在iOS 8上使用Xcode 7执行,第1张

概述我在3台设备上测试我的应用程序. iOS 9上的2个设备和iOS 8上的一个设备.在iOS 9上,当我滑动一个单元格时,editActionsForRowAtIndexPath的功能正在运行,并且显示动作.但是在iOS 8中,我无法滑动单元格. 这是我的代码: func tableView(tableView: UITableView, editActionsForRowAtIndexPath i 我在3台设备上测试我的应用程序. iOS 9上的2个设备和iOS 8上的一个设备.在iOS 9上,当我滑动一个单元格时,editactionsForRowAtIndexPath的功能正在运行,并且显示动作.但是在iOS 8中,我无法滑动单元格.

这是我的代码:

func tableVIEw(tableVIEw: UItableVIEw,editactionsForRowAtIndexPath indexPath: NSIndexPath) -> [UItableVIEwRowAction]? {    let ShareAction = UItableVIEwRowAction(style: .normal,Title: "Partager",handler: { (action: UItableVIEwRowAction!,indexPath: NSIndexPath!) -> VoID in        if AllArticle[indexPath.row].Title != nil && AllArticle[indexPath.row].link != nil {            var ToShare = []            if self.search {                ToShare = [ArticleFiltered[indexPath.row].link!]            } else {                ToShare = [AllArticle[indexPath.row].link!]            }            let ActivityVIEwController = UIActivityVIEwController(activityItems: ToShare as [AnyObject],applicationActivitIEs: nil)            self.presentVIEwController(ActivityVIEwController,animated: true,completion: {                self.tableVIEw.setEditing(false,animated: true)            })        }    })    let FavoriteAction = UItableVIEwRowAction(style: .normal,Title: "Ajouté aux favoris",indexPath: NSIndexPath!) -> VoID in        if AllArticle[indexPath.row].Favoris {            let alreadyInVIEw = UIAlertController(Title: "Favori déjà ajouté",message: "Cet article fait déjà parti de vos favoris",preferredStyle: .Alert)            let ActionAlert = UIAlertAction(Title: "Ok",style: .Default) { (action) in }            alreadyInVIEw.addAction(ActionAlert)            self.presentVIEwController(alreadyInVIEw,completion: nil)        } else {            AllArticle[indexPath.row].Favoris = true            let alreadyInVIEw = UIAlertController(Title: "Favori ajouté",message: "Cet article fait maintenant parti de vos favoris",completion: nil)            Favorite.append(indexPath.row)            saveFavoris()        }        self.tableVIEw.setEditing(false,animated: true)    })    FavoriteAction.backgroundcolor = UIcolor.redcolor()    return [ShareAction,FavoriteAction]}

当然我加入了

vIEwDIDLoad中()

if tableVIEw != nil {        tableVIEw.delegate = self        tableVIEw.dataSource = self        tableVIEw.tableFooterVIEw = UIVIEw(frame: CGRectZero)        tableVIEw.addGestureRecognizer(UITapGestureRecognizer(target: self,action: "taptableVIEw"))        tableVIEw.gestureRecognizers?.last?.delegate = self    }

可能它的Xcode错误?
有任何想法吗 ?

谢谢 !

在iOS 8下,只有在委托中实现了commitEditingStyle调用时,才能启用editactions.在tableVIEwController中添加bellow方法:
- (voID)tableVIEw:(UItableVIEw*)tableVIEw commitEditingStyle:(UItableVIEwCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath*)indexPath{    // All tasks are handled by blocks defined in editactionsForRowAtIndexPath,however iOS8 requires this method to enable editing}
总结

以上是内存溢出为你收集整理的swift – editActionsForRowAtIndexPath不能在iOS 8上使用Xcode 7执行全部内容,希望文章能够帮你解决swift – editActionsForRowAtIndexPath不能在iOS 8上使用Xcode 7执行所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1040112.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-24
下一篇 2022-05-24

发表评论

登录后才能评论

评论列表(0条)

保存