@IBOutlet weak var vacationImageVIEw: UIImageVIEw!@IBOutlet weak var percentSaved: UILabel!@IBOutlet weak var cost: UILabel!@IBOutlet weak var saved: UILabel!@IBOutlet weak var circleProgressVIEw: CircularProgressVIEw!@IBOutlet weak var daysDepart: UILabel!
我打电话给popover,我想将保存的当前文本值发送到我的d出窗口,允许用户编辑它并将其发送回视图.这是我的popover电话.
@IBAction func addPopover(sender: UIVIEw) { let savingsinformationVIEwController = storyboard?.instantiateVIEwControllerWithIDentifIEr("SavingsAddPopover") as UIVIEwController savingsinformationVIEwController.modalPresentationStyle = .Popover savingsinformationVIEwController.preferredContentSize = CGSizeMake(200,200) let popoverController = savingsinformationVIEwController.popoverPresentationController popoverController?.sourceVIEw = sender popoverController?.permittedArrowDirections = .Any popoverController?.delegate = self presentVIEwController(savingsinformationVIEwController,animated: true,completion: nil)}
我会以为我可以引用popover中的数据对象,但是至少不是我的想法.
解决方法class VIEwController: UIVIEwController,SavingVIEwControllerDelegate,UIPopoverPresentationControllerDelegate{ @IBOutlet var labelText: UILabel! overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() // Do any additional setup after loading the vIEw,typically from a nib. } @IBAction func buttonPopOverClick(sender: UIbutton) { let savingsinformationVIEwController = storyboard?.instantiateVIEwControllerWithIDentifIEr("SavingsAddPopoverVC") as SavingVIEwController savingsinformationVIEwController.delegate = self savingsinformationVIEwController.strSaveText=labelText.text savingsinformationVIEwController.modalPresentationStyle = .Popover if let popoverController = savingsinformationVIEwController.popoverPresentationController { popoverController.sourceVIEw = sender popoverController.sourceRect = sender.bounds popoverController.permittedArrowDirections = .Any popoverController.delegate = self } presentVIEwController(savingsinformationVIEwController,completion: nil) } func saveText(strText: Nsstring) { labelText.text=strText } // MARK: - UIPopoverPresentationControllerDelegate func adaptivePresentationStyleForPresentationController(controller: UIPresentationController!) -> UIModalPresentationStyle { return .FullScreen } func presentationController(controller: UIPresentationController!,vIEwControllerForAdaptivePresentationStyle style: UIModalPresentationStyle) -> UIVIEwController! { return UINavigationController(rootVIEwController: controller.presentedVIEwController) } } protocol SavingVIEwControllerDelegate { func saveText(var strText : Nsstring) } class SavingVIEwController: UIVIEwController { @IBOutlet var textFIEld: UITextFIEld! var delegate : SavingVIEwControllerDelegate? var strSaveText : Nsstring! overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() textFIEld.text = strSaveText // Do any additional setup after loading the vIEw. } @IBAction func buttonDone(sender: UIbutton) { if (self.delegate) != nil { delegate?.saveText(textFIEld.text) self.dismissVIEwControllerAnimated(true,nil) } } }总结
以上是内存溢出为你收集整理的ios – 将数据传递到Swift中的Popover全部内容,希望文章能够帮你解决ios – 将数据传递到Swift中的Popover所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)