这是我的代码:
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执行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)