UIVIEwController中:
class WhoToOdds: UIVIEwController,sendBack,UITextFIEldDelegate{ @IBOutlet var chosenContact: UITextFIEld! @IBOutlet var oddsTextBox: UITextVIEw! var frIEnd: String? overrIDe func vIEwWillAppear(animated: Bool) { super.vIEwWillAppear(animated) navigationController?.setNavigationbarHIDden(false,animated: true) } func sendnametoprevIoUsVC(selectedfrIEndname: String) { frIEnd = selectedfrIEndname chosenContact.text = frIEnd } overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // Do any additional setup after loading the vIEw,typically from a nib. } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. } overrIDe func prepareForSegue(segue: UIStoryboardSegue,sender: AnyObject?) { if segue.IDentifIEr == "frIEndList"{ let frIEndVIEwController = (segue.destinationVIEwController as! frIEndListController) var fbRequest = FBSDKGraphRequest(graPHPath:"/me/frIEnds",parameters: nil); fbRequest.startWithCompletionHandler { (connection : FBSDKGraphRequestConnection!,result : AnyObject!,error : NSError!) -> VoID in if error == nil { println("FrIEnds are : \(result)") PFUser.currentUser()?["frIEnd_List"] = result PFUser.currentUser()?.save() print(result) var resultdict = result as! NSDictionary println("Result Dict: \(resultdict)") frIEndVIEwController.frIEndarray = resultdict.objectForKey("data") as! NSArray } } } } @IBAction private func submitChallenge(sender: AnyObject) { navigationController?.popVIEwControllerAnimated(true) }}@H_404_14@tableVIEwController:
protocol sendBack{ func sendnametoprevIoUsVC(contact: String) } class frIEndListController: UItableVIEwController,UItableVIEwDataSource,UItableVIEwDelegate{ var frIEndarray:NSArray = ["a","b","c"] var valueDict:NSDictionary = [:] var mDelegate:sendBack? var selectedFrIEnd :String? overrIDe func vIEwWillAppear(animated: Bool) { super.vIEwWillAppear(animated) navigationController?.setNavigationbarHIDden(false,animated: true) } overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() } overrIDe func tableVIEw(tableVIEw: UItableVIEw,numberOfRowsInSection section: Int) -> Int { return frIEndarray.count } overrIDe func tableVIEw(tableVIEw: UItableVIEw,cellForRowAtIndexPath indexPath: NSIndexPath) -> UItableVIEwCell { let cell = tableVIEw.dequeueReusableCellWithIDentifIEr("frIEnd",forIndexPath: indexPath) as! UItableVIEwCell cell.textLabel!.text = (frIEndarray[indexPath.row] as! String) return cell } overrIDe func tableVIEw(tableVIEw: UItableVIEw,dIDSelectRowAtIndexPath indexPath: NSIndexPath){ let indexPath = tableVIEw.indexPathForSelectedRow(); let currentCell = tableVIEw.cellForRowAtIndexPath(indexPath!) as UItableVIEwCell! selectedFrIEnd = currentCell.textLabel!.text as String! sendBackFrIEndList(selectedFrIEnd!) navigationController?.popVIEwControllerAnimated(true) } func sendBackFrIEndList(name: String){ self.mDelegate?.sendnametoprevIoUsVC(name) }}@H_404_14@解决方法 您的代表需要设置.在你的情况下,你必须在prepareForSegue方法中设置它overrIDe func prepareForSegue(segue: UIStoryboardSegue,sender: AnyObject?) {if segue.IDentifIEr == "frIEndList"{ let frIEndVIEwController = (segue.destinationVIEwController as! frIEndListController) frIEndVIEwController.mDelegate = self //Include this line//rest of the code}}@H_404_14@ 总结以上是内存溢出为你收集整理的ios – 选择表格视图单元格后,将数据传回上一个视图控制器全部内容,希望文章能够帮你解决ios – 选择表格视图单元格后,将数据传回上一个视图控制器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)