gpt4 book ai didi

ios - Facebook 注册在 if 语句中使用了错误的 segue - Swift

转载 作者:行者123 更新时间:2023-11-30 13:52:30 25 4
gpt4 key购买 nike

因此,在我的 iOS 应用程序的第一个屏幕上,我有一个“登录”、“注册”和一个“通过 Facebook 注册”按钮。前两个按钮可以很好地链接到它们自己的 View Controller ,一旦登录模拟器将自动使用以下命令登录它们:

if PFUser.currentUser() != nil {

self.performSegueWithIdentifier("autoSegue", sender: self)

} else {

您可以在下面完整代码块的底部看到代码。然而,Facebook 注册我想转换到一个单独的 View Controller ,在那里我可以向他们展示他们的个人资料图片,捕获 Parse 上的数据,让他们输入用户名,然后转到注册和登录所转到的同一 View Controller -自动继续。我已经写出了该 View Controller 上的所有代码,但我的问题是,当他们单击 Facebook 的注册按钮时,它会通过 autoSegue 而不是 fbSignup segue(链接到我想要捕获的位置的那个) FB 数据)。两个 Segues 都直接从 View Controller 链接(而不是按钮本身),并且我没有收到任何构建错误。我感谢任何帮助。

谢谢!

完整代码:

import UIKit

import Parse

import MediaPlayer

import FBSDKCoreKit







class ViewController: UIViewController {

@IBOutlet var loginAlpha: UIButton!

@IBOutlet var signupAlpha: UIButton!




var avPlayer: AVPlayer!

var avPlayerLayer: AVPlayerLayer!

var paused: Bool = false





@IBAction func facebookSignup(sender: AnyObject) {



let permissions = ["public_profile"]



PFFacebookUtils.logInInBackgroundWithReadPermissions(permissions) { (user: PFUser?, error: NSError?) -> Void in



if let error = error {



print(error)



} else {



if let user = user {



self.performSegueWithIdentifier("fbSignup", sender: self)

}





}





}







}

override func viewDidLoad() {

super.viewDidLoad()




// code for background video



let theURL = NSBundle.mainBundle().URLForResource("test", withExtension: "mp4")



avPlayer = AVPlayer(URL: theURL!)

avPlayerLayer = AVPlayerLayer(player: avPlayer)

avPlayerLayer.videoGravity = AVLayerVideoGravityResizeAspectFill

avPlayer.volume = 0

avPlayer.actionAtItemEnd = AVPlayerActionAtItemEnd.None



avPlayerLayer.frame = view.layer.bounds

view.backgroundColor = UIColor.clearColor();

view.layer.insertSublayer(avPlayerLayer, atIndex: 0)



NSNotificationCenter.defaultCenter().addObserver(self,

selector: "playerItemDidReachEnd:",

name: AVPlayerItemDidPlayToEndTimeNotification,

object: avPlayer.currentItem)

}



func playerItemDidReachEnd(notification: NSNotification) {

let p: AVPlayerItem = notification.object as! AVPlayerItem

p.seekToTime(kCMTimeZero)

}



override func viewDidAppear(animated: Bool) {



if PFUser.currentUser() != nil {



self.performSegueWithIdentifier("autoSegue", sender: self)

} else {







signupAlpha.alpha = 0

loginAlpha.alpha = 0



UIView.animateWithDuration(1.5, delay: 1.0, options: [], animations: { () -> Void in

self.signupAlpha.alpha = 1.0

self.loginAlpha.alpha = 1.0



}, completion: nil)



avPlayer.play()

paused = false

}

}



override func viewDidDisappear(animated: Bool) {

avPlayer.pause()

paused = true

}







override func didReceiveMemoryWarning() {

super.didReceiveMemoryWarning()

// Dispose of any resources that can be recreated.

}

}

最佳答案

您正在使用 Storyboard吗?您可能搞乱了 Storyboard并将 Segue 连接到了错误的 ViewController。

我看不出您的代码有什么特别错误。

关于ios - Facebook 注册在 if 语句中使用了错误的 segue - Swift,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34090743/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com