ios - UIActivity view controller crashing -
i have activity controller, crashes , dont understand why. code:
func screenshotmethod() { //create uiimage let image = view?.snapshot //save camera roll uiimagewritetosavedphotosalbum(image, nil, nil, nil) self.socialshare(sharingtext: "text", sharingimage: image, sharingurl:nsurl(string: "itms-apps://itunes.apple.com/app/bars/xxxxxxxx")) } func socialshare(#sharingtext: string?, sharingimage: uiimage?, sharingurl: nsurl?) { var sharingitems = [anyobject]() if let text = sharingtext { sharingitems.append(text) } if let image = sharingimage { sharingitems.append(image) } if let url = sharingurl { sharingitems.append(url) } let activityviewcontroller = uiactivityviewcontroller(activityitems: sharingitems, applicationactivities: nil) activityviewcontroller.excludedactivitytypes = [uiactivitytypecopytopasteboard,uiactivitytypeairdrop,uiactivitytypeaddtoreadinglist,uiactivitytypeassigntocontact,uiactivitytypeposttotencentweibo,uiactivitytypeposttovimeo,uiactivitytypeprint,uiactivitytypesavetocameraroll,uiactivitytypeposttoweibo] var currentviewcontroller:uiviewcontroller=uiapplication.sharedapplication().keywindow!.rootviewcontroller! currentviewcontroller.presentviewcontroller(activityviewcontroller, animated: true, completion: nil) sharebutton.alpha = 1.0 }
and here uiview snapshot extension:
extension uiview { var snapshot: uiimage { uigraphicsbeginimagecontextwithoptions(bounds.size, false, uiscreen.mainscreen().scale) drawviewhierarchyinrect(bounds, afterscreenupdates: true) let result = uigraphicsgetimagefromcurrentimagecontext() uigraphicsendimagecontext() return result } }
and here errors getting:
thread : fatal exception: nsgenericexception 0 corefoundation 0x25a14fef __exceptionpreprocess 1 libobjc.a.dylib 0x33e00c8b objc_exception_throw 2 uikit 0x2970ae63 -[uipopoverpresentationcontroller presentationtransitionwillbegin] 3 uikit 0x2934209d __71-[uipresentationcontroller _initviewhierarchyforpresentationsuperview:]_block_invoke 4 uikit 0x29340a17 __56-[uipresentationcontroller runtransitionforcurrentstate]_block_invoke 5 uikit 0x290e4a91 _applyblocktocfarraycopiedtostack 6 uikit 0x2905f38f _aftercacommithandler 7 corefoundation 0x259dafed __cfrunloop_is_calling_out_to_an_observer_callback_function__ 8 corefoundation 0x259d86ab __cfrunloopdoobservers 9 corefoundation 0x259d8ab3 __cfrunlooprun 10 corefoundation 0x25925201 cfrunlooprunspecific 11 corefoundation 0x25925013 cfrunloopruninmode 12 graphicsservices 0x2d101201 gseventrunmodal 13 uikit 0x290c9a59 uiapplicationmain 14 void 0x000ba600 main (appdelegate.swift:19) 15 libdyld.dylib 0x3438caaf start
and
thread : crashed: com.apple.main-thread 0 void 0x0013aa90 function signature specialization <arg[0] = owned guaranteed , exploded, arg[1] = owned guaranteed, arg[2] = owned guaranteed> of a_void.gamescene.touchesmoved (a_void.gamescene)(swift.set<objectivec.nsobject>, withevent : objectivec.uievent) -> () (gamescene.swift:2036) 1 void 0x0013a950 function signature specialization <arg[0] = owned guaranteed , exploded, arg[1] = owned guaranteed, arg[2] = owned guaranteed> of a_void.gamescene.touchesmoved (a_void.gamescene)(swift.set<objectivec.nsobject>, withevent : objectivec.uievent) -> () (gamescene.swift:2026) 2 void 0x0010b2bc @objc a_void.gamescene.touchesmoved (a_void.gamescene)(swift.set<objectivec.nsobject>, withevent : objectivec.uievent) -> () (gamescene.swift) 3 spritekit 0x28f0a8af -[skview touchesmoved:withevent:] + 710 4 uikit 0x2909a46b -[uiwindow _sendtouchesforevent:] + 350 5 uikit 0x29093df1 -[uiwindow sendevent:] + 544 6 uikit 0x29069fe5 -[uiapplication sendevent:] + 196 7 uikit 0x292e08fb _uiapplicationhandleeventfromqueueevent + 14414 8 uikit 0x290689f9 _uiapplicationhandleeventqueue + 1352 9 corefoundation 0x259dafaf __cfrunloop_is_calling_out_to_a_source0_perform_function__ + 14 10 corefoundation 0x259da3bf __cfrunloopdosources0 + 218 11 corefoundation 0x259d8a25 __cfrunlooprun + 772 12 corefoundation 0x25925201 cfrunlooprunspecific + 476 13 corefoundation 0x25925013 cfrunloopruninmode + 106 14 graphicsservices 0x2d101201 gseventrunmodal + 136 15 uikit 0x290c9a59 uiapplicationmain + 1440 16 void 0x0014d600 main (appdelegate.swift:19) 17 libdyld.dylib 0x3438caaf start + 2
the app game made sprite kit, calling game method inside skscene. also, game game view controller 1 controlling game scene , embed navigation view controller, in present gamecenter. nows how fix this?
Comments
Post a Comment