ios - Screenshot of previous UIViewController after orientation changed -
i implemented described in post: send screenshot of viewcontroller other viewcontroller
but have issue after orientation changed in 'profileviewcontroller'. tried screenshot of 'viewcontroller' image of view in previous orientation.
i tried things this, nothing appears help:
override func viewwilltransitiontosize(size: cgsize, withtransitioncoordinator coordinator: uiviewcontrollertransitioncoordinator) { coordinator.animatealongsidetransition(nil, completion: { (context : uiviewcontrollertransitioncoordinatorcontext!) -> void in var viewcontroller = self.navigationcontroller!.viewcontrollers[0] as! uiviewcontroller viewcontroller.view.setneedsdisplay() viewcontroller.view.setneedslayout() viewcontroller.view.layoutifneeded() self.backgroundimage = viewcontroller.getimagedump() }) super.viewwilltransitiontosize(size, withtransitioncoordinator: coordinator) } 'getimagedump' extension method on uiviewcontroller:
func getimagedump() -> uiimage { var size = view.bounds.size uigraphicsbeginimagecontextwithoptions(size, true, 0); view.layer.renderincontext(uigraphicsgetcurrentcontext()) var image = uigraphicsgetimagefromcurrentimagecontext(); uigraphicsendimagecontext(); return image } edit: fixed it; set size of viewcontroller manually. instead of
viewcontroller.view.setneedsdisplay() viewcontroller.view.setneedslayout() viewcontroller.view.layoutifneeded() just do
viewcontroller.view.frame.size = size
use snapshot instead
- (uiview *)snapshotviewafterscreenupdates:(bool)afterupdates;
Comments
Post a Comment