2015-08-28 17 views
13

Uygulamamı 3 cihazda deniyorum. IOS 9'da 2 cihaz ve iOS 8'de bir cihaz. IOS 9'da editActionsForRowAtIndexPath işlevi çalışıyor ve bir hücreyi kaydırdığımda eylem gösteriliyor. Ancak iOS 8'de hücreleri kaydırmam.editActionsForRowAtIndexPod Xcode 7 ile iOS 8 üzerinde çalışmaz

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", handler: { (action: UITableViewRowAction!, 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, animated: true, completion: nil) 
     } else { 
      AllArticle[indexPath.row].Favoris = true 
      let alreadyInView = UIAlertController(title: "Favori ajouté", message: "Cet article fait maintenant parti de vos favoris", preferredStyle: .Alert) 
      let ActionAlert = UIAlertAction(title: "Ok", style: .Default) { (action) in } 
      alreadyInView.addAction(ActionAlert) 
      self.presentViewController(alreadyInView, animated: true, completion: nil) 
      Favorite.append(indexPath.row) 
      saveFavoris() 
     } 
     self.TableView.setEditing(false, animated: true) 
    }) 

    FavoriteAction.backgroundColor = UIColor.redColor() 

    return [ShareAction, FavoriteAction] 
} 

Ve tabii ki

eklenen

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 
    } 

onun Xcode hata Mayıs: Burada

benim kodudur? Herhangi bir fikrin var mı?

Teşekkürler!

+0

Aynı sorunu yaşıyorum. Her şey iOS 9'da iyi çalışıyor ancak 8'de değil. –

+0

Xcode Gold Master bu hatayı düzeltti mi? –

+0

Hata hala Xcode GM ile burada, bizim prog –

cevap

41

iOS 8 kapsamında, düzenleme, yalnızca temsilcinize commitEditingStyle çağrısı uygulandığında etkinleştirilir. özel UITableViewCell varsa

- (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 
} 
0

ve GestureRecognizer orada var, temsilci yöntemleri kontrol - shouldRecognizeSimultaneouslyWithGestureRecognizer:

+0

StackOverflow'a Hoş Geldiniz. Cevabınız biraz belirsiz geliyor, bunu detaylandırır mısınız? Lütfen ne hakkında konuştuğunuzu açıklayın ya da bunları OP'nin vakasına nasıl uygulayacağınızı gösterin. – YakovL

0

sınıfa bu temsilci yöntemi ekleme: tableViewController içinde feryat yöntemi ekleyin.

func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) { 
     if editingStyle == UITableViewCellEditingStyle.Delete { 
    } 
} 
İlgili konular