ios - How to present new ViewController and dismiss the current from memory -


how present new viewcontroller , dismiss current memory

 var presentingviewcontroller :uiviewcontroller! = self.presentingviewcontroller;      self.dismissviewcontrolleranimated(false) {         // go mainmenuview eyes of user         presentingviewcontroller.dismissviewcontrolleranimated(false, completion: nil)      } 

this ok want present before dismiss can show loading indicator

let loadingnotification = mbprogresshud.showhudaddedto(self.view, animated: true)     loadingnotification.labeltext = "retrieving data" 

if takes long time before view containing "retrieving data" appears, there time consuming logic in initialization code. should consider moving viewdidappear or background thread. way presented view controller gets shown right away (with initial state of "retrieving data".

another way of doing create intermediate view controller shows "retrieveing data" message, present instead of new view controller , make present new 1 upon completion of data retrieving process.

the solution depend on mechanisms using implement data retrieval. whether synchrounous or asynchronous have big impact on how approach it.

as general rule, should avoid placing time sensitive or cpu intensive code in initialization functions such viewdidload, viewwillappear ...


Comments

Popular posts from this blog

get url and add instance to a model with prefilled foreign key :django admin -

css - Make div keyboard-scrollable in jQuery Mobile? -

ruby on rails - Seeing duplicate requests handled with Unicorn -