Show Game Centre Leaderboard not working in swift - ios

I am coding in swift and I am getting the following error message from my submit button. The leaderboard does not show up in the simulator, just gives me the error message below
<GKGameCenterViewController: 0x7a8d0800> on <Chinese_Quiz.OpeningViewController: 0x78688aa0> whose view is not in the window hierarchy!
Below is all the game centre code from my app.
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
Randomize()
Hide()
authenticateLocalPlayer()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func Submit(sender: AnyObject) {
saveHighscore(Score)
showLeaderboard()
}
func authenticateLocalPlayer(){
var localPlayer = GKLocalPlayer.localPlayer()
localPlayer.authenticateHandler = {(viewController, error) -> Void in
if (viewController != nil) {
self.presentViewController(viewController, animated: true, completion: nil)
}
else {
println((GKLocalPlayer.localPlayer().authenticated))
}
}
}
func gameCenterViewControllerDidFinish(gameCenterViewController: GKGameCenterViewController!)
{
gameCenterViewController.dismissViewControllerAnimated(true, completion: nil)
}
func showLeaderboard() {
var vc = self.view?.window?.rootViewController
var gc = GKGameCenterViewController()
gc.gameCenterDelegate = self
vc?.presentViewController(gc, animated: true, completion: nil)
}
func saveHighscore(score:Int) {
//check if user is signed in
if GKLocalPlayer.localPlayer().authenticated {
var scoreReporter = GKScore(leaderboardIdentifier: "ChineseWeather") //leaderboard id here
scoreReporter.value = Int64(Score) //score variable here (same as above)
var scoreArray: [GKScore] = [scoreReporter]
GKScore.reportScores(scoreArray, withCompletionHandler: {(error : NSError!) -> Void in
if error != nil {
println("error")
}
})
}
}

Solved by turning this:
func showLeaderboard() {
var vc = self.view?.window?.rootViewController
var gc = GKGameCenterViewController()
gc.gameCenterDelegate = self
vc?.presentViewController(gc, animated: true, completion: nil)
}
Into this:
func showLeaderboard() {
var vc = self
var gc = GKGameCenterViewController()
var gameCenterDelegate: GKGameCenterControllerDelegate!
// Above text was replaced from gc.gameCenterDelegate = self
vc.presentViewController(gc, animated: true, completion: nil)
}
I don't know why, but it worked.

Related

Game centre issues when viewing leaderboard and scores

I've integrated Game Centre into my app the following way:
When the game loads
func authPlayer(){
let localPlayer = GKLocalPlayer.localPlayer()
localPlayer.authenticateHandler = {
(view, error) in
if view != nil {
self.present(view!, animated: true, completion: nil)
}
else {
print(GKLocalPlayer.localPlayer().isAuthenticated)
}
}
}
And then in the gameOver scene:
func saveHighscore(_ number : Int){
if GKLocalPlayer.localPlayer().isAuthenticated {
let scoreReporter = GKScore(leaderboardIdentifier: "...")
scoreReporter.value = Int64(number)
let scoreArray : [GKScore] = [scoreReporter]
GKScore.report(scoreArray, withCompletionHandler: nil)
}
}
func showLeaderboard() {
let gameCenter = GKGameCenterViewController()
gameCenter.gameCenterDelegate = self
gameCenter.viewState = GKGameCenterViewControllerState.leaderboards
if let gameViewController = self.view?.window?.rootViewController {
gameViewController.show(gameCenter, sender: self)
gameViewController.navigationController?.pushViewController(gameCenter, animated: true)
}
}
Some devices can't find the leaderboard, other devices can find it but only have their score showing etc.
Have I missed something?
Authenticating works fine.

ViewController loads but does not show

I'm using the Spotify iOS SDK. When a user logs into Spotify using the app, on call back loginVC transitions to musicPlayerVC. But, when a user logs into the app using a web view, once the web view dismisses and the loginVC is shown, the musicPlayerVC is loaded (print statements from viewDidLoad occur), but loginVC does not dismiss and musicPlayerVC does not show.
loginVC:
class loginVC: UIViewController, SPTStoreControllerDelegate, WebViewControllerDelegate {
#IBOutlet weak var statusLabel: UILabel!
var authViewController: UIViewController?
var firstLoad: Bool!
var Information: [String:String]?
override func viewDidLoad() {
super.viewDidLoad()
// NotificationCenter.default.addObserver(self, selector: #selector(self.sessionUpdatedNotification), name: NSNotification.Name(rawValue: "sessionUpdated"), object: nil)
self.statusLabel.text = ""
self.firstLoad = true
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
NotificationCenter.default.addObserver(self, selector: #selector(self.sessionUpdatedNotification), name: NSNotification.Name(rawValue: "sessionUpdated"), object: nil)
let auth = SPTAuth.defaultInstance()
// Uncomment to turn off native/SSO/flip-flop login flow
//auth.allowNativeLogin = NO;
// Check if we have a token at all
if auth!.session == nil {
self.statusLabel.text = ""
return
}
// Check if it's still valid
if auth!.session.isValid() && self.firstLoad {
// It's still valid, show the player.
print("View did load, still valid, showing player")
self.showPlayer()
return
}
// Oh noes, the token has expired, if we have a token refresh service set up, we'll call tat one.
self.statusLabel.text = "Token expired."
if auth!.hasTokenRefreshService {
self.renewTokenAndShowPlayer()
return
}
// Else, just show login dialog
}
override var prefersStatusBarHidden: Bool {
return true
}
func getAuthViewController(withURL url: URL) -> UIViewController {
let webView = WebViewController(url: url)
webView.delegate = self
return UINavigationController(rootViewController: webView)
}
func sessionUpdatedNotification(_ notification: Notification) {
self.statusLabel.text = ""
let auth = SPTAuth.defaultInstance()
self.presentedViewController?.dismiss(animated: true, completion: { _ in })
if auth!.session != nil && auth!.session.isValid() {
self.statusLabel.text = ""
print("Session updated, showing player")
self.showPlayer()
}
else {
self.statusLabel.text = "Login failed."
print("*** Failed to log in")
}
}
func showPlayer() {
self.firstLoad = false
self.statusLabel.text = "Logged in."
self.Information?["SpotifyUsername"] = SPTAuth.defaultInstance().session.canonicalUsername
OperationQueue.main.addOperation {
[weak self] in
self?.performSegue(withIdentifier: "ShowPlayer", sender: self)
}
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ShowPlayer" {
if let destination = segue.destination as? PlayController {
destination.Information = self.Information
}
}
}
internal func productViewControllerDidFinish(_ viewController: SPTStoreViewController) {
self.statusLabel.text = "App Store Dismissed."
viewController.dismiss(animated: true, completion: { _ in })
}
func openLoginPage() {
self.statusLabel.text = "Logging in..."
let auth = SPTAuth.defaultInstance()
if SPTAuth.supportsApplicationAuthentication() {
self.open(url: auth!.spotifyAppAuthenticationURL())
} else {
self.authViewController = self.getAuthViewController(withURL: SPTAuth.defaultInstance().spotifyWebAuthenticationURL())
self.definesPresentationContext = true
self.present(self.authViewController!, animated: true, completion: { _ in })
}
}
func open(url: URL) {
if #available(iOS 10, *) {
UIApplication.shared.open(url, options: [:],
completionHandler: {
(success) in
print("Open \(url): \(success)")
})
} else {
let success = UIApplication.shared.openURL(url)
print("Open \(url): \(success)")
}
}
func renewTokenAndShowPlayer() {
self.statusLabel.text = "Refreshing token..."
SPTAuth.defaultInstance().renewSession(SPTAuth.defaultInstance().session) { error, session in
SPTAuth.defaultInstance().session = session
if error != nil {
self.statusLabel.text = "Refreshing token failed."
print("*** Error renewing session: \(error)")
return
}
self.showPlayer()
}
}
func webViewControllerDidFinish(_ controller: WebViewController) {
// User tapped the close button. Treat as auth error
}
}
webController :
import UIKit
import WebKit
#objc protocol WebViewControllerDelegate {
func webViewControllerDidFinish(_ controller: WebViewController)
/*! #abstract Invoked when the initial URL load is complete.
#param success YES if loading completed successfully, NO if loading failed.
#discussion This method is invoked when SFSafariViewController completes the loading of the URL that you pass
to its initializer. It is not invoked for any subsequent page loads in the same SFSafariViewController instance.
*/
#objc optional func webViewController(_ controller: WebViewController, didCompleteInitialLoad didLoadSuccessfully: Bool)
}
class WebViewController: UIViewController, UIWebViewDelegate {
var loadComplete: Bool = false
var initialURL: URL!
var webView: UIWebView!
var delegate: WebViewControllerDelegate?
override func viewDidLoad() {
super.viewDidLoad()
print(initialURL)
let initialRequest = URLRequest(url: self.initialURL)
self.webView = UIWebView(frame: self.view.bounds)
self.webView.delegate = self
self.webView.autoresizingMask = [.flexibleWidth, .flexibleHeight]
self.view.addSubview(self.webView)
self.navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .done, target: self, action: #selector(self.done))
self.webView.loadRequest(initialRequest)
}
func done() {
self.delegate?.webViewControllerDidFinish(self)
self.presentingViewController?.dismiss(animated: true, completion: { _ in })
}
func webViewDidFinishLoad(_ webView: UIWebView) {
if !self.loadComplete {
delegate?.webViewController?(self, didCompleteInitialLoad: true)
self.loadComplete = true
}
}
func webView(_ webView: UIWebView, didFailLoadWithError error: Error) {
if !self.loadComplete {
delegate?.webViewController?(self, didCompleteInitialLoad: true)
self.loadComplete = true
}
}
init(url URL: URL) {
super.init(nibName: nil, bundle: nil)
self.initialURL = URL as URL!
}
required init?(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
}
}

How to remove memory leak using UIWebView?

I have a UIWebView and inside that I have to load a url.
Problem is that After opening webView Memory leak is happened.
I mean I am not able to remove memory leak.
Here below is my code :-
import UIKit
import Toast_Swift
class WebViewController: UIViewController,UIWebViewDelegate {
//WebView
#IBOutlet weak var webView: UIWebView!
//URL
var strUrl : String? = nil
//Tag
var tag : Int! = 0
//ViewDidLoad
override func viewDidLoad() {
super.viewDidLoad()
//Delegate of web view
webView.delegate = self
//webView.stringByEvaluatingJavaScript(from: "localStorage.clear();")
self.webView.loadRequest(URLRequest(url: URL(string: self.strUrl!)!))
//Loading View
self.view.makeToastActivity(.center)
}
//MARK :- Web view delegate.
func webViewDidFinishLoad(_ webView: UIWebView) {
//ToastManager.shared.tapToDismissEnabled = true
self.view.hideToastActivity()
}
//Button Back Action
#IBAction func btnBack(_ sender: Any) {
if (tag == 1) {
webView.delegate = nil
self.strUrl = ""
webView.removeCache()
let gotoCreateView = self.storyboard?.instantiateViewController(withIdentifier: "CreateAccountView") as! CreateAccountView
self.present(gotoCreateView, animated: true, completion: nil)
} else {
webView.delegate = nil
self.strUrl = ""
webView.removeCache()
let gotoAboutUsView = self.storyboard?.instantiateViewController(withIdentifier: "AboutUsView") as! AboutUsView
self.present(gotoAboutUsView, animated: true, completion: nil)
}
/*if (1 == tag)
{
webView.delegate = nil
webView.removeCache()
let gotoCreateView = self.storyboard?.instantiateViewController(withIdentifier: "CreateAccountView") as! CreateAccountView
self.present(gotoCreateView, animated: true, completion: nil)
}
else
{
webView.delegate = nil
webView.removeCache()
let gotoAboutUsView = self.storyboard?.instantiateViewController(withIdentifier: "AboutUsView") as! AboutUsView
self.present(gotoAboutUsView, animated: true, completion: nil)
}*/
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
webView.delegate = nil
webView.removeCache()
webView.delegate = self
self.webView.reload()
}
}
extension UIWebView
{
func removeCache()
{
URLCache.shared.removeAllCachedResponses()
URLCache.shared.diskCapacity = 0
URLCache.shared.memoryCapacity = 0
if let cookies = HTTPCookieStorage.shared.cookies {
for cookie in cookies {
HTTPCookieStorage.shared.deleteCookie(cookie)
}
}
}
}
What can I do to remove memory leak?
Thanks
Apart from your code, you need to get these points:
The first thing is try to not add the webView in main view, instead of this you can set alpha or hidden property. If you are using hidden property, then on unhiding make their delegate set to nil and try to manage that WebView will not work in background when it is hidden.
If you are showing in new ViewController, then when we are pushing the WebView, set their delegate and reload the request. Now when you are trying to back from that view. Before poping, set their delegate to nil, set nil to all the local variables that are used in it.
For Example:
On ViewDidLoad: you are setting delegate,
Now when you pop, means move to previous screen use these lines of code:
webView.delegate = nil
webView.removeCache()
And,
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
webView.delegate = nil
webView.removeCache()
webView.delegate = self
self.webView.reload()
}
}
And on Back button:
#IBAction func btnBack(_ sender: Any) {
if (tag == 1) {
webView.delegate = nil
self.strUrl = ""
webView.removeCache()
let gotoCreateView = self.storyboard?.instantiateViewController(withIdentifier: "CreateAccountView") as! CreateAccountView
self.present(gotoCreateView, animated: true, completion: nil)
} else {
webView.delegate = nil
self.strUrl = ""
webView.removeCache()
let gotoAboutUsView = self.storyboard?.instantiateViewController(withIdentifier: "AboutUsView") as! AboutUsView
self.present(gotoAboutUsView, animated: true, completion: nil)
}
}

Parse Login self.logInViewController ambiguous reference to member ' logInViewController'

I am using parse's provided login code for their latest ParseUI. I am confused why I am getting this error every single time I use self.logInViewController and self.signUpViewController, the error being:
Ambiguous reference to member 'logInViewController' and 'signUpViewController'
Here is my code:
import Parse
import ParseUI
import UIKit
class ViewController: UIViewController, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate {
#IBAction func simpleAction(sender: AnyObject) {
self.presentViewController(self.logInViewController, animated: true, completion: nil)
}
#IBAction func customAction(sender: AnyObject) {
self.performSegueWithIdentifier("custom", sender: self)
}
#IBAction func logoutAction(sender: AnyObject) {
PFUser.logOut()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(animated)
if (PFUser.currentUser() == nil) {
self.logInViewController.fields = PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton
var logInLogoTitle = UILabel()
logInLogoTitle.text = "Parse"
self.logInViewController.logInView.logo = logInLogoTitle
self.logInViewController.delegate = self
var SignUpLogoTitle = UILabel()
SignUpLogoTitle.text = "Parse"
self.signUpViewController.signUpView.logo = SignUpLogoTitle
self.signUpViewController.delegate = self
self.logInViewController.signUpController = self.signUpViewController
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func logInViewController(logInController: PFLogInViewController!, shouldBeginLogInWithUsername username: String!, password: String!) -> Bool {
if (!username.isEmpty || !password.isEmpty) {
return true
}else {
return false
}
}
func logInViewController(logInController: PFLogInViewController!, didLogInUser user: PFUser!) {
self.dismissViewControllerAnimated(true, completion: nil)
}
func logInViewController(logInController: PFLogInViewController!, didFailToLogInWithError error: NSError!) {
print("Failed to login...")
}
func logInViewControllerDidCancelLogIn(logInController: PFLogInViewController!) {
}
func signUpViewController(signUpController: PFSignUpViewController!, didSignUpUser user: PFUser!) {
self.dismissViewControllerAnimated(true, completion: nil)
}
func signUpViewController(signUpController: PFSignUpViewController!, didFailToSignUpWithError error: NSError!) {
print("FAiled to sign up...")
}
func signUpViewControllerDidCancelSignUp(signUpController: PFSignUpViewController!) {
print("User dismissed sign up.")
}
}
logInViewController and signUpViewController are both undefined.
You need to define them with:
let logInViewController = PFLogInViewController()
let signUpViewController = PFSignUpViewController()

performSegueWithIdentifier not working after Signup with Parse

I'm using performSegueWithIdentifier and everything is OK on all of them, but there is one that doesnt work at all.
I'm using Parse.com to signup a user and I want to perform a segue after they sigup, but I can't get it to work. I think the performSegue should be place at function signUpViewController
My code:
import UIKit
import Parse
import ParseUI
import Bolts
import FBSDKCoreKit
import FBSDKLoginKit
import FBSDKShareKit
import CoreLocation
struct localizacaoActualizada {
static var rua = ""
static var localidade = ""
static var codigopostal = ""
static var giropostal = ""
static var country = ""
}
class ViewController: UIViewController, ENSideMenuDelegate, PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate, CLLocationManagerDelegate {
var logInViewController: PFLogInViewController! = PFLogInViewController()
var signUpViewController: PFSignUpViewController! = PFSignUpViewController()
var localidadeActual = ""
#IBOutlet weak var userLogedIn: UILabel!
let locationManager = CLLocationManager()
override func viewDidLoad() {
super.viewDidLoad()
self.sideMenuController()?.sideMenu?.delegate = self
self.locationManager.delegate = self
self.locationManager.desiredAccuracy = kCLLocationAccuracyBest
self.locationManager.requestWhenInUseAuthorization()
self.locationManager.requestAlwaysAuthorization()
self.locationManager.startUpdatingLocation()
// Se ta loggado
var user = PFUser.currentUser()
if (user?.username != nil) {
// self.performSegueWithIdentifier("aposLogin", sender: self)
}
}
override func viewDidAppear(animated: Bool) {
super.viewDidAppear(true)
var user = PFUser.currentUser()
self.userLogedIn.text = user?.username
if (user?.username == nil) {
self.logInViewController.fields = ( PFLogInFields.UsernameAndPassword | PFLogInFields.LogInButton | PFLogInFields.SignUpButton | PFLogInFields.PasswordForgotten | PFLogInFields.DismissButton )
//PFLogInFields.Facebook
var logInLogoTitle = UILabel()
logInLogoTitle.text = "ParaFora"
var SignUpLogoTitle = UILabel()
SignUpLogoTitle.text = "ParaFora"
//self.logInViewController.facebookPermissions = [ "friends_about_me" ]
self.logInViewController.logInView!.logo = logInLogoTitle
self.logInViewController.delegate = self
self.signUpViewController.signUpView!.logo = SignUpLogoTitle
self.signUpViewController.delegate = self
self.logInViewController.signUpController = self.signUpViewController
}
else {
//Tentativa 1
//self.locationManager.stopUpdatingLocation()
var user = PFUser.currentUser()
user?["localidade"] = localidadeActual
user?.saveInBackground()
//tentativa 2
//var user = PFUser.currentUser()
//var idUser = user?["objectId"] as! String
// println("O id do utilizador actual:" + idUser)
// var query = PFQuery(className:"User")
// query.getObjectInBackgroundWithId(idUser) {
// (User: PFObject?, error: NSError?) -> Void in
// if error != nil {
// println(error)
// } else if let User = User {
// println("Tentativa de escrever" + self.localidadeActual + "no servidor")
// User["localidade"] = self.localidadeActual
// User.saveInBackground()
// println("done?")
// }
// }
//
// self.performSegueWithIdentifier("aposLogin", sender: self)
}
}
//Localizacao
func locationManager(manager: CLLocationManager!, didUpdateLocations locations: [AnyObject]!)
{
CLGeocoder().reverseGeocodeLocation(manager.location, completionHandler: {(placemarks, error)->Void in
if (error != nil)
{
println("Error: " + error.localizedDescription)
return
}
if placemarks.count > 0
{
let pm = placemarks[0] as! CLPlacemark
self.displayLocationInfo(pm)
}
else
{
println("Error with the data.")
}
})
}
func displayLocationInfo(placemark: CLPlacemark)
{
locationManager.stopUpdatingLocation()
//self.locationManager.stopUpdatingLocation()
println(placemark.locality)
println(placemark.postalCode)
println(placemark.administrativeArea)
println(placemark.country)
println(placemark.location)
println(placemark.administrativeArea)
println(placemark.subAdministrativeArea)
// println(placemark.addressDictionary)
// println(placemark.areasOfInterest)
localidadeActual = placemark.locality
localizacaoActualizada.rua = placemark.name
localizacaoActualizada.localidade = placemark.locality
//Guarda o codigo postal na estrutura
if count(placemark.postalCode) > 4{
localizacaoActualizada.codigopostal = placemark.postalCode.substringWithRange(Range<String.Index>(start: advance(placemark.postalCode.startIndex, 0), end: advance(placemark.postalCode.endIndex, -3)))
localizacaoActualizada.giropostal = placemark.postalCode.substringWithRange(Range<String.Index>(start: advance(placemark.postalCode.startIndex, 4), end: advance(placemark.postalCode.endIndex, 0)))
}
else {
localizacaoActualizada.codigopostal = placemark.postalCode
}
// Obtem a localidade no serv
var user = PFUser.currentUser()
println(user?["localidade"])
//fim obter localidade
}
func locationManager(manager: CLLocationManager!, didFailWithError error: NSError!)
{
println("Error: " + error.localizedDescription)
}
//fim local
// MARK: Parse Login
func logInViewController(logInController: PFLogInViewController, shouldBeginLogInWithUsername username: String, password: String) -> Bool {
if (!username.isEmpty || !password.isEmpty) {
return true
}else {
return false
}
}
func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil)
self.performSegueWithIdentifier("aposLogin", sender: self)
}
func logInViewController(logInController: PFLogInViewController, didFailToLogInWithError error: NSError?) {
println("Failed to login...")
}
func logInViewControllerDidCancelLogIn(logInController: PFLogInViewController) {
}
// MARK: Parse Signup
func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil)
self.performSegueWithIdentifier("setupCliente", sender:self)
}
func signUpViewController(signUpController: PFSignUpViewController, didFailToSignUpWithError error: NSError?) {
println("FAiled to sign up...")
}
func signUpViewControllerDidCancelSignUp(signUpController: PFSignUpViewController) {
println("User dismissed sign up.")
}
// MARK: Actions
#IBAction func simpleAction(sender: AnyObject) {
self.presentViewController(self.logInViewController, animated: true, completion: nil)
}
#IBAction func logoutAction(sender: AnyObject) {
PFUser.logOut()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
#IBAction func toggleSideMenu(sender: AnyObject) {
toggleSideMenuView()
}
// MARK: - ENSideMenu Delegate
func sideMenuWillOpen() {
println("sideMenuWillOpen")
}
func sideMenuWillClose() {
println("sideMenuWillClose")
}
func sideMenuShouldOpenSideMenu() -> Bool {
println("sideMenuShouldOpenSideMenu")
return true
}
}
In your signUpViewController function you are dismissing the current view controller and then you are calling performSegueWithIdentifier with the sender as the view controller you just dismissed. Try removing the dismissViewControllerAnimated method call
I had the same problem. But I managed to solve it, although it is not a perfect solution.
What I did was to dismiss the PFSignUpViewController.
But before I did that I set a global variable, a bool called initialSignUp in my case to true. Once the controller was dismissed I checked in the PFLogInViewController's viewDidAppear() method if initialSignUp was true.
If this was the case I changed it back to false and then performed the segue.
This workaround works for me and I hope I could help you with your problem.
I think you need to set the delegate of the loginViewController's signupViewController. Something like this (sorry it's in swift, but you can propably work it out):
let loginViewController = LoginViewController()
loginViewController.delegate = self
loginViewController.signUpController?.delegate = self
and then, you can call the following methods to dismiss the view and perform the segue (or anything else).
func logInViewController(logInController: PFLogInViewController, didLogInUser user: PFUser) {
self.dismissViewControllerAnimated(true, completion: nil)
self.performSegueWithIdentifier("segueID")
}
func signUpViewController(signUpController: PFSignUpViewController, didSignUpUser user: PFUser) -> Void {
self.dismissViewControllerAnimated(true, completion: nil)
self.performSegueWithIdentifier("segueID")
}
Hope this help. It worked for me.
Cheers,
Julien

Resources