xcode - Programmatically switching views swift -
xcode - Programmatically switching views swift -
i trying out apple's new language swift in xcode 6 beta. trying programmatically switch views when table view cell pressed, although pull blank black screen. in code, commented out things didn't work. create ios simulator crash. code:
// viewcontroller.swift // step-by-step tip calculator // created dani smith on 6/17/14. // copyright (c) 2014 dani smith productions. rights reserved. import uikit var billtotalposttax = 0 class billinfoviewcontroller: uiviewcontroller { //outlets @iboutlet var totaltextfield: uitextfield @iboutlet var taxpctlabel: uilabel @iboutlet var resultstextview: uitextview @iboutlet var taxpcttextfield : uitextfield //variables var billtotalvar = "" var taxpctvar = "" //actions override func viewdidload() { super.viewdidload() refreshui() } override func didreceivememorywarning() { super.didreceivememorywarning() // dispose of resources can recreated. } @ibaction func steponenextpressed(sender : anyobject) { billtotalvar = totaltextfield.text taxpctvar = taxpcttextfield.text } @ibaction func calculatetipped(sender : anyobject) { tipcalc.total = double(totaltextfield.text.bridgetoobjectivec().doublevalue) allow possibletips = tipcalc.returnpossibletips() var results = "" (tippct, tipvalue) in possibletips { results += "\(tippct)%: \(tipvalue)\n" } resultstextview.text = results } /* @ibaction func taxpercentagechanged(sender : anyobject) { tipcalc.taxpct = string(taxpcttextfield.text) / 100 refreshui() }*/ @ibaction func viewtapped(sender : anyobject) { totaltextfield.resignfirstresponder() } allow tipcalc = tipcalculatormodel(total: 33.25, taxpct: 0.06) func refreshui() { //totaltextfield.text = string(tipcalc.total) } } class restauranttableviewcontroller: uitableviewcontroller { override func tableview(tableview: uitableview!, didselectrowatindexpath indexpath: nsindexpath!) { allow row = indexpath?.row println(row) //let vc:billinfoviewcontroller = billinfoviewcontroller() //let vc = self.storyboard.instantiateviewcontrollerwithidentifier("billinfo") uinavigationcontroller //self.presentviewcontroller(vc, animated: true, completion: nil) } }
thank much of help.
i figured out. had make
let vc = self.storyboard.instantiateviewcontrollerwithidentifier("billinfo")`
to
let vc : anyobject! = self.storyboard.instantiateviewcontrollerwithidentifier("billinfo")
to quiet warning. changed presentviewcontroller
showviewcontroller
, , worked. here completed class:
class restauranttableviewcontroller: uitableviewcontroller { override func tableview(tableview: uitableview!, didselectrowatindexpath indexpath: nsindexpath!) { allow row = indexpath?.row println(row) allow vc : anyobject! = self.storyboard.instantiateviewcontrollerwithidentifier("billinfo") self.showviewcontroller(vc uiviewcontroller, sender: vc) } }
xcode view swift xcode6
Comments
Post a Comment