Facebook登录后麻烦推送到PFQueryTableViewController [英] Trouble Pushing to PFQueryTableViewController after Facebook Login

查看:100
本文介绍了Facebook登录后麻烦推送到PFQueryTableViewController的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功登录Facebook。登录视图是一个UIViewController。我只能通过使用

  @interface LoginViewController访问Parses的登录功能:UIViewController< PFLogInViewControllerDelegate,PFSignUpViewControllerDelegate> 

问题是,一旦我成功登录,我希望用户看到一个PFQueryTableViewController。应用程序都是基于列表的,所以推送这个是有道理的。



我尝试过:

   - (void)logInViewController :( PFLogInViewController *)logInController didLogInUser:(PFUser *)user 
{
[self dismissViewControllerAnimated:YES完成:^ {
NSLog(@成功登录);
MyPFQueryTableViewController * controller = [[MyPFQueryTableViewController alloc] init];

//不知道该怎么办...


}];

}

最初我推到了TableView。我已经删除了该代码,坦白说,我不知道我是怎么做到的。



但是发生了什么,我看到UIViewController一会儿,然后显示PFQueryTableViewController。



不仅如此,即使表格嵌入在导航控制器中,PFQueryTableViewController也没有显示导航栏。



这是我的LoginViewController.m的代码

  #import LoginViewController.h
#import< Parse / Parse.h>
#importMyPFQueryTableViewController.h

@interface LoginViewController()

@end

@implementation LoginViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if(self){
//自定义初始化
}
return self;
}


- (void)viewDidLoad
{
[super viewDidLoad];
PFLogInViewController * login = [[PFLogInViewController alloc] init];
login.fields = PFLogInFieldsFacebook;
//需要将代理设置为此控制器。
login.delegate = self;
login.signUpController.delegate = self; // signUpController是登录视图控制器上的一个属性
[self presentModalViewController:login animated:NO];


//加载视图后执行任何其他设置。
}



/ *
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
UINavigationController * navigationController = segue.destinationViewController;
MyPFQueryTableViewController * controller =(MyPFQueryTableViewController *)
navigationController.topViewController;





- (void)viewDidAppear:(BOOL)动画
{

MyPFQueryTableViewController * controller =
[[MyPFQueryTableViewController alloc] initWithClassName:@Lists];
[self presentViewController:controller animated:NO completion:nil];

}
* /




//以下四个委托方法。

- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user
{
[self dismissViewControllerAnimated:YES完成:^ {
NSLog @成功登录);
MyPFQueryTableViewController * controller = [[MyPFQueryTableViewController alloc] init];

//不知道该怎么做...
}];

}

我以为也许我需要使用segue方法,但是我不太确定



更新:



下面的答案我试图推送登录通过在MyPFQueryTableViewController.m文件中的presentModalViewController。

   - (void)viewDidLoad {
[super viewDidLoad];

//取消注释以下行以保留演示文稿之间的选择。
// self.clearsSelectionOnViewWillAppear = NO;

//取消注释以下行,以在此视图控制器的导航栏中显示编辑按钮。
PFLogInViewController * login = [[PFLogInViewController alloc] init];
login.fields = PFLogInFieldsFacebook;
login.delegate = self;
login.signUpController.delegate = self;
[self presentModalViewController:login animated:NO];

//self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

看到我的下面的评论,我得到的警告。

解决方案

一个选项是将PFQueryTableViewController作为初始视图控制器,并在应用程序启动时以模态方式呈现LoginViewController。这是当我在我的一个应用程序中使用Parse时所做的,


I log in successfully with Facebook. The Login view is a UIViewController. I can only get access to Parses' login feature by using

@interface LoginViewController : UIViewController <PFLogInViewControllerDelegate, PFSignUpViewControllerDelegate>

The problem is, once I successfully login, I'd like the user to see a PFQueryTableViewController. The app is all based on lists so, it makes sense to push to this.

I tried this:

- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user
{
    [self dismissViewControllerAnimated:YES completion:^{ 
        NSLog(@"Successfully logged in.");
        MyPFQueryTableViewController *controller = [[MyPFQueryTableViewController alloc] init];

        //Not sure what to do here...


       }];

}

Originally I pushed to the TableView. I've since deleted that code and frankly I have no idea how I did it.

But what happened was I see the UIViewController for a brief second, and then the PFQueryTableViewController appears.

Not only that but the PFQueryTableViewController didn't show a navigation bar, even though the table is embedded in a navigation controller.

Here's the code for my LoginViewController.m

#import "LoginViewController.h"
#import <Parse/Parse.h>
#import "MyPFQueryTableViewController.h"

@interface LoginViewController ()

@end

@implementation LoginViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}


 - (void)viewDidLoad
 {
 [super viewDidLoad];
     PFLogInViewController *login = [[PFLogInViewController alloc] init];
     login.fields = PFLogInFieldsFacebook;
     // Need to set the delegate to be this controller.
     login.delegate = self;
     login.signUpController.delegate = self; //signUpController is a property on the login view controller
     [self presentModalViewController:login animated:NO];


 // Do any additional setup after loading the view.
 }



/*
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    UINavigationController *navigationController = segue.destinationViewController;
    MyPFQueryTableViewController *controller = (MyPFQueryTableViewController *)
    navigationController.topViewController;


}


- (void)viewDidAppear:(BOOL)animated
{

    MyPFQueryTableViewController *controller =
    [[MyPFQueryTableViewController alloc] initWithClassName:@"Lists"];
    [self presentViewController:controller animated:NO completion:nil];

}
*/




//Four delegation methods below.

- (void)logInViewController:(PFLogInViewController *)logInController didLogInUser:(PFUser *)user
{
    [self dismissViewControllerAnimated:YES completion:^{ 
        NSLog(@"Successfully logged in.");
        MyPFQueryTableViewController *controller = [[MyPFQueryTableViewController alloc] init];

        //Not sure what to do here...
    }];

}

I thought maybe I need to use the segue method, but I'm not too sure.

Update:

Per below answer I'm trying to push the login via presentModalViewController in the MyPFQueryTableViewController.m file.

- (void)viewDidLoad {
    [super viewDidLoad];

    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;

    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    PFLogInViewController *login = [[PFLogInViewController alloc] init];
    login.fields = PFLogInFieldsFacebook;
    login.delegate = self;
    login.signUpController.delegate = self;
    [self presentModalViewController:login animated:NO];

    //self.navigationItem.rightBarButtonItem = self.editButtonItem;
}

See my below comment for the warning I'm getting.

解决方案

One option would be to have PFQueryTableViewController as the initial view controller and present the LoginViewController modally when the application starts. This is what I did when I used Parse in one of my apps

这篇关于Facebook登录后麻烦推送到PFQueryTableViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆