2014-11-09 47 views
0

得到回調在一個錶行點擊我引用的單元來呈現一個視圖控制器在Rubymotion如何從解僱視圖控制器

def open_selector    
    view_b = ImagesController.new #using rmq hence .new   
    @@cell.superview.superview.controller.presentViewController view_b, animated:true, completion:nil 
    end 

中的圖像控制器(從圖像列表中選擇) - 我解僱當完成選擇時 - 但我如何讓細胞知道它已關閉?

def collectionView(view, didSelectItemAtIndexPath: index_path) 

    self.dismissViewControllerAnimated(true, completion: lambda{}) 

end 
+0

典型..在幾分鐘後形成它。基本上你可以從View1中設置delegate = self,並在View2的委託上調用方法。 – MikeW 2014-11-09 03:46:45

回答

0

我建議您提供您的UICollectionViewController委託,以便它可以回調自己。所以:

class MyCollectionViewController < UICollectionViewController 
    attr_writer :parent_controller 

    # ... 

    def collectionView(view, didSelectItemAtIndexPath: index_path) 
    self.dismissViewControllerAnimated(true, 
             completion: lambda{ 
             @parent_controller.collection_did_close(self) 
             }) 
    end 

假設,您有一個名爲collection_did_close父控制器的方法,它將以集合視圖控制器的引用調用。使用它可以在垃圾收集之前獲取所需的任何信息。

相關問題