ios - Correct way to display today view widget content -
i'm working on today view extension custom view elements don't set in interface builder.
now i'm wondering right point in lifecycle init widget content.
i read updating content in widgetperformupdatewithcompletionhandler implemented check new updates should view.
but observations showed me method called before viewdidappearand there no view update. tought widget stays in memory while can have object in widgetperformupdatewithcompletionhandler content can update , utilize in viewdidappear isn't case (it loads every time)
so right way: write content disk in widgetperformupdatewithcompletionhandler, can depend on in memory or ignore , refresh on every load?
in todayviewcontroller.m -viewdidload() method called each time open notification. when ever check today widget phone call -viewdidload(). customisation in -viewdidload(). unless don't want check previous state.
straight blog helps create today widget real time data:
creating today widget
caching can take advantage of nsuserdefaults save calculated used space between launches. lifecycle of widget short if cache value, can set user interface initial value , calculate actual value.
edit:
from apple documentation state that
to help widget date, scheme captures snapshots of widget’s view. when widget becomes visible again, recent snapshot displayed until scheme replaces live version of view.
it state notification center, can widget details of state , snapshot.
not sure this, state below method used both widget , containing app check content. there no much details how widget snapshot.
func sethascontent(_ flag: bool, forwidgetwithbundleidentifier bundleid: string!) ncwidgetcontroller sethascontent
ios cocoa-touch ios-app-extension
No comments:
Post a Comment