ios - Navigation like in the mail app with segues and dynamic cells in a table view? -


i'm developing first ios app college. when start app, there grouped table view should represent menu. works fine far, i'm unable connect segues properly. far know should connect cell navigation controller should lead to. although every cell should lead navigation controller. it's menu, point should clear. unfortunately i'm unable connect single cell multiple navigation controllers , when add multiple prototype cells, have problem every cell should have it's own identifier.

the first screen see in app looks mail app. there 2 groups , each cell leads navigation controller.

i managed implement navigation in weird way, lot of bugs "nested push results in corrupted nav bar".

i'm absolutely frustrated right now, spent lot of hours on single problem , i'm unable find solution.

edit: 1 of biggest problems if navigate point , head the view before, grouped view first displayed close top , when animation complete whole view jumps down belongs.

this how should (and looks when jumps back): https://dl.dropboxusercontent.com/u/34140308/uploads/2016-04-25%2010.28.48.png

this how looks during animation: https://dl.dropboxusercontent.com/u/34140308/uploads/2016-04-25%2010.28.48%202.png

edit2: connected view controller (not cells) respective view controller. call segues programmatically this:

override func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {     tableview.deselectrowatindexpath(indexpath, animated: true)     if indexpath.section == 0 {         if indexpath.row == 0 {             self.performseguewithidentifier("showspeiseplan", sender: self)         } else if indexpath.row == 1 {             self.performseguewithidentifier("showstudiersaal", sender: self)         } else if indexpath.row == 2 {             self.performseguewithidentifier("showerzieher", sender: self)         } else if indexpath.row == 3 {             self.performseguewithidentifier("showhausordnung", sender: self)         } else if indexpath.row == 4 {             self.performseguewithidentifier("shownews", sender: self)         }     } else if indexpath.section == 1 {         if indexpath.row == 0 {             self.performseguewithidentifier("showzugewiesenestunden", sender: self)         }     } } 

the other major problem right if press single cell multiple times before it's loaded, view gets opened multiple times well.

the way segue's tableview connecting segue viewcontroller rather tableviewcells. way can call performseguewithidentifier in didselectrowatindexpath.

eg

func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) {      tableview.deselectrowatindexpath(indexpath, animated: true)     tableview.userinteractionenabled = false      switch indexpath.section {     case 0:         switch indexpath.row {         case 0: performseguewithidentifier("showspeiseplan", sender: self)         case 1: performseguewithidentifier("showstudiersaal", sender self)         case 2: performseguewithidentifier("showerzieher", sender self)         case 3: performseguewithidentifier("showhausordnung", sender self)         case 4: performseguewithidentifier("shownews", sender self)         default: tableview.userinteractionenabled = true         }     case 1:         switch indexpath.row {         case 0: performseguewithidentifier("showzugewiesenestunden", sender: self)         default: tableview.userinteractionenabled = true         }     default: tableview.userinteractionenabled = true     } } 

and in viewwilldisappear:

 override func viewdiddisappear(animated: bool) {     tableview.userinteractionenabled = true  } 

if cells editable or dynamic (they change indexpath) either use cell.tag in cellforrowatindexpath distinguish them, or add property custom cell class (or make 1 if haven't) , add property can use identify correct segue.

edit: fix tableview offset jump on animation, create variable tableviewcontentoffset above viewdidload, , in viewdidload add:

 tableviewcontentoffset = tableview.contentoffset 

and in viewwillappear restore if has changed.

if tableview.contentoffset != tableviewcontentoffset {     tableview.contentoffset = tableviewcontentoffset } 

also, maybe see happens when put in viewwillappear:

tableview.contentoffset = cgpointzero tableview.contentinset = uiedgeinsetszero 

Comments

Popular posts from this blog

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -