ios - navigationController is nil while performing segue? -
i using library called swiftpages. works fine. when perform push segue view controller navigation bar self.navigationcontroller nil ?
how can add navigation bar pushed vc ?
viewcontroller
class coursepagecontroller: uiviewcontroller, uitableviewdatasource, uitableviewdelegate { @iboutlet weak var chaptertable: uitableview! @iboutlet weak var coursedesc: uitextview! var coursename : string! var chapname : [string] = [] var chapid : [string] = [] override func viewdidload() { super.viewdidload() self.title = coursename self.coursedesc.text = coursedescriptionc self.coursedesc.setcontentoffset(cgpointzero, animated: true) hud() chaptertable.estimatedrowheight = 120 chaptertable.rowheight = uitableviewautomaticdimension getdata() } func hud(){ progress.show(style: mystyle()) } func getdata(){ alamofire.request(.get, "http://www.wve.com/index.php/capp/get_chapter_by_course_id/\(courseidincontroller)") .responsejson { (_, _, data, _) in let json = json(data!) let catcount = json.count index in 0...catcount-1 { let cname = json[index]["chapter_name"].string let cid = json[index]["chapter_id"].string self.chapname.append(cname!) self.chapid.append(cid!) } self.chaptertable.reloaddata() self.progress.dismiss() } } func numberofsectionsintableview(tableview: uitableview) -> int { // #warning potentially incomplete method implementation. // return number of sections. return 1 } func tableview(tableview: uitableview, numberofrowsinsection section: int) -> int { // #warning incomplete method implementation. // return number of rows in section. return chapname.count } func tableview(tableview: uitableview, cellforrowatindexpath indexpath: nsindexpath) -> uitableviewcell { let cell : uitableviewcell = self.chaptertable.dequeuereusablecellwithidentifier("chapcell") as! uitableviewcell cell.textlabel?.text = self.chapname[indexpath.row] return cell } func tableview(tableview: uitableview, didselectrowatindexpath indexpath: nsindexpath) { //here navigationcontroller nil self.navigationcontroller?.pushviewcontroller(self.storyboard!.instantiateviewcontrollerwithidentifier("lessoncontroller") as! uiviewcontroller, animated: true) // performseguewithidentifier("chapsegue", sender: nil) }
edit
i have added navigation controller initial vc. course page controller shown swiftpages.
i can't find how being presented. please take @ file. https://github.com/gabrielalva/swiftpages/blob/master/swiftpages/swiftpages.swift
thanks in advance!
did put coursepagecontroller in navigationcontroller? if yes check how presented?
if presented modally won't navigationcontroller reference.
this work if have navcontroller rootviewcontroller
if let navcontroller = uiapplication.sharedapplication().keywindow?.rootviewcontroller as? uinavigationcontroller { //get nav controller here , try push anotherviewcontroller }
Comments
Post a Comment