Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/xcode/7.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xcode 使用segue form UITabBarItem传递数据不工作_Xcode_Swift_Segue_Uitabbar - Fatal编程技术网

Xcode 使用segue form UITabBarItem传递数据不工作

Xcode 使用segue form UITabBarItem传递数据不工作,xcode,swift,segue,uitabbar,Xcode,Swift,Segue,Uitabbar,我想将数据从一个UIView传递到另一个UIView,以便访问根据用户选择的UIAbbarItem而不同的网站。我怎么做 func pathButton(dcPathButton: DCPathButton!, clickItemButtonAtIndex itemButtonIndex: UInt) { switch itemButtonIndex { case 0: // working but can’t send data with it sel

我想将数据从一个UIView传递到另一个UIView,以便访问根据用户选择的UIAbbarItem而不同的网站。我怎么做

func pathButton(dcPathButton: DCPathButton!, clickItemButtonAtIndex itemButtonIndex: UInt) {

    switch itemButtonIndex {

    case 0:

     // working but can’t send data with it
     self.performSegueWithIdentifier("goto", sender: self) 

     // not working as function is not trigger
    func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
        if segue.identifier == "goto" {
            let vc = segue.destinationViewController as! WebMainViewController
            vc.goURL = "http://google.com“

        dcPathButton.delegate = self

        println(“go to http//google.com”)
        }
    case 1:
        println(“go to http://apple.com”)
    case 2:
        println(“go to http://imbd.com”)
    case 3:
        println(“go to http://facebook.com”)
    default:
        println(“go to http://cnn.com”)
    }
你试过了吗

func pathButton(dcPathButton: DCPathButton!, clickItemButtonAtIndex itemButtonIndex: UInt) {
switch itemButtonIndex {
case 0:
   self.performSegueWithIdentifier("goto", sender: self) 
   // plus other cases
}
然后在课程的另一个部分中实现:

func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject!) {
    if segue.identifier == "goto" {
        let vc = segue.destinationViewController as! WebMainViewController
        vc.goURL = "http://google.com“
}
显然,确保您的segue已连接,并将“goto”设置为标识符

也许您可以在
prepareforsgue
中使用一些逻辑来设置
vc.goul
,而不是您当前使用的switch语句?例如,用户选择一个特定值,您将该值保存到一个变量中,然后当他们单击按钮启动序列时,您检查该变量的值并相应地设置
vc.goul