ios - How to redraw my view in SWIFT? -


on ipad app, have uiviewcontroller button open modalview.

@ibaction func showpostcommentviewcontroller(sender: anyobject){      let modalview = uistoryboard(name: "main", bundle: nil).instantiateviewcontrollerwithidentifier("postcommentviewcontroller") as! postcommentviewcontroller     modalview.modaltransitionstyle = uimodaltransitionstyle.coververtical     modalview.modalpresentationstyle = uimodalpresentationstyle.formsheet     modalview.delegate=self     self.presentviewcontroller(modalview, animated: true, completion: nil) } 

when close modalview dismissviewcontrolleranimated, "refresh" view controller (because added new content). modal view "formsheet" style, viewdidappear or viewwillappear aren't called.

i tried use setneedsdisplay, doesn't work.

i don't know how do.

this perfect use case delegate pattern.

1) define protocol within postcommentviewcontroller.

protocol postcommentvcinformationdelegate {     func hasdismissedpostcommentviewcontroller(controller:postcommentviewcontroller) } 

2) set delegate variable within postcommentviewcontroller

var delegate: postcommentvcinformationdelegate? 

3) when dismiss postcommentviewcontroller, call delegate?.hasdismissedpostcommentviewcontroller(self)

this send information presenting vc.

4) have our presenting view controller conform protocol.

class viewcontroller: uiviewcontroller, postcommentvcinformationdelegate 

5) when presenting modal view:

modalview.delegate = self 

6) finally, implement:

func hasdismissedpostcommentviewcontroller(controller: postcommentviewcontroller) {     //update } 

Comments

Popular posts from this blog

c# - Better 64-bit byte array hash -

webrtc - Which ICE candidate am I using and why? -

php - Zend Framework / Skeleton-Application / Composer install issue -