ios - ViewController persist through segue -


i don't know how explain problem show here video showing problem(s) having: https://youtu.be/dfiwenmj6xc

as can see push segue sloppy. want keep alerts label in top right correct data, , not have flash. image go away , not have jitter visible. here part of code in first view class:

class weatherviewcontroller: uiviewcontroller, locationservicedelegate, uiviewcontrollerpreviewingdelegate{      var fromwarnignsviewcontroller = false     var weatheralerts: weatheralerts!     var locationfixachieved : bool = false     var locationstatus : nsstring = "not started"     var userlocation : string!     var userlatitude : double!     var userlongitude : double!     var usertemperaturecelsius : bool!     var hourlyweather2: hourly!     var weeklyyweather2: weekly!      override func viewdidload() {         super.viewdidload()         }      override func viewwilltransitiontosize(size: cgsize, withtransitioncoordinator coordinator: uiviewcontrollertransitioncoordinator) {                 super.viewwilltransitiontosize(size, withtransitioncoordinator: coordinator)     }      override func viewdidappear(animated: bool) {         super.viewdidappear(animated);         if (!fromwarnignsviewcontroller){             let currentlocation = locationservice.sharedinstance.lastlocation             userlatitude = currentlocation?.coordinate.latitude             userlongitude = currentlocation?.coordinate.longitude             let defaults: nsuserdefaults = nsuserdefaults.standarduserdefaults()             usertemperaturecelsius = defaults.boolforkey("celsius")             self.warningslabel.hidden = true         }     }      func getcurrentweatherdata() -> void {          let baseurl = nsurl(string: "https://api.forecast.io/forecast/\(apikey)/")         let forecasturl = nsurl(string: "\(userlocation)", relativetourl:baseurl)         let sharedsession = nsurlsession.sharedsession()              let downloadtask: nsurlsessiondownloadtask = sharedsession.downloadtaskwithurl(forecasturl!, completionhandler: { (location: nsurl?, response: nsurlresponse?, error: nserror?) -> void in               if (error == nil) {                  let dataobject = nsdata(contentsofurl: location!)                 let weatherdictionary = (try! nsjsonserialization.jsonobjectwithdata(dataobject!, options: [])) as! nsdictionary                  let currentweather = current(weatherdictionary: weatherdictionary)                 let weeklyweather = weekly(weatherdictionary: weatherdictionary)                 self.hourlyweather2 = hourly(weatherdictionary: weatherdictionary)                 self.weeklyyweather2 = weeklyweather                  let hourlyweather = self.hourlyweather2                 dispatch_async(dispatch_get_main_queue(), {                     self.weatheralerts = weatheralerts(weatherdictionary: weatherdictionary)                     if(self.weatheralerts.useralert.count > 0){                         self.warningslabel.hidden = false;                         let buttontitle = string(self.weatheralerts.useralert.count) + " alerts"                          self.warningslabel.settitle(buttontitle, forstate: uicontrolstate.normal)                         self.warningslabel.enabled = true                      } else {                         self.warningslabel.hidden = true;                         let buttontitle = "0 alerts"                         self.warningslabel.settitle(buttontitle, forstate: uicontrolstate.normal)                         self.warningslabel.enabled = false                     }                 });              }         })          downloadtask.resume()     }          override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {          if (segue.identifier == "warnings") {             let svc = segue.destinationviewcontroller as! warningsviewcontroller;              svc.weatheralerts = self.weatheralerts             svc.userlocation = self.userlocation             svc.userlatitude = self.userlatitude             svc.userlongitude = self.userlongitude             svc.hourlyweather2 = self.hourlyweather2             svc.weeklyyweather2 = self.weeklyyweather2             svc.weatherviewcontroller = self         }     }      func tracinglocation(currentlocation: cllocation) {         // if application active         if uiapplication.sharedapplication().applicationstate == .active {             self.userlatitude = currentlocation.coordinate.latitude;             self.userlongitude = currentlocation.coordinate.longitude;             activelocationupdate(currentlocation)             getcurrentweatherdata()         }     } } 

and here code in alert view:

class warningsviewcontroller: uiviewcontroller {     var weatherviewcontroller: weatherviewcontroller!     var weatheralerts: weatheralerts!     var userlocation : string!     var userlatitude : double!     var userlongitude : double!     var hourlyweather2: hourly!     var weeklyyweather2: weekly!      override func prepareforsegue(segue: uistoryboardsegue, sender: anyobject?) {         print(weatheralerts.useralert)          if (segue.identifier == "embed") {             let svc = segue.destinationviewcontroller as! warningtableviewcontroller;              svc.weatheralerts = self.weatheralerts          } else if (segue.identifier == "back") {             let svc = segue.destinationviewcontroller as! weatherviewcontroller;             svc.weatheralerts = self.weatheralerts             svc.userlocation = self.userlocation             svc.userlatitude = self.userlatitude             svc.userlongitude = self.userlongitude             svc.hourlyweather2 = self.hourlyweather2             svc.weeklyyweather2 = self.weeklyyweather2             svc.fromwarnignsviewcontroller = true         }       } } 

it's lot of code don't know how condense. greatlhy appreciated!


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -