'forum'没有可见的@interface声明选择器'backToLastPage'

时间:2013-10-08 04:14:50

标签: ios objective-c facebook uiwebview

所以我对xCode很新,如果有人可以帮助我,这会有所帮助!

我正在创建一个非常简单的应用程序。我有UIWebView把我带到移动页面。此页面包含Facebook登录。我一直遇到的原始问题是,因为它是一个移动网站,我在登录完成后会看到一个空白屏幕。我需要UIWebView将我带回我点击登录的原始签名。我已经复制了一些我认为可行的代码,但是我收到的错误是

  

“'论坛'没有可见的@interface'声明选择器'backToLastPage'”

有人可以告诉我我需要做些什么来解决这个问题吗?它可能很简单,但我需要一些帮助。

#import "forum.h"
#import "ViewController.h"

@interface forum ()

@end

@implementation forum



-(IBAction)switchback:(id)sender {
    [self dismissViewControllerAnimated:YES completion:nil];
}


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


- (void)viewDidLoad
{
    [super viewDidLoad];
    NSURL *myURL = [NSURL URLWithString:@"http://www.moot.it/yopyipcommunity"];
    NSURLRequest *myRequest = [NSURLRequest requestWithURL:myURL];
    [myWebView loadRequest:myRequest];
}

- (BOOL)webView:(UIWebView *)webView 
        shouldStartLoadWithRequest:(NSURLRequest *)request 
        navigationType:(UIWebViewNavigationType)navigationType
{
    NSString *url = [[request URL] absoluteString];

    //when user status == connected 
    //(has a access_token at facebook oauth response)
    if([url hasPrefix:@"https://m.facebook.com/dialog/oauth"] && 
       [url rangeOfString:@"access_token="].location != NSNotFound)
    {
        [self backToLastPage];
        return NO;
    }

    return YES;
}

- (void)webViewDidFinishLoad:(UIWebView *)webView
{
    NSString *url = [[webView.request URL] absoluteString];

    if([url hasPrefix:@"https://m.facebook.com/dialog/oauth"])
    {
        NSString *bodyHTML = 
       [webView stringByEvaluatingJavaScriptFromString:@"document.body.innerHTML"];

        //Facebook oauth response dead end: 
        //  is a blank body and a head with a script that does
        //nothing. But if you got back to your last page, 
        //  the handler of authResponseChange
        //will catch a connected status 
        //  if user did his login and auth app
        if([bodyHTML isEqualToString:@""])
        {
            [self backToLastPage];
        }
    }   
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end

1 个答案:

答案 0 :(得分:0)

我认为forum.h是单独的类,在该类中声明了backToLastPage方法。

@property (nonatomic, strong) forum *forum;

您需要为该类创建分配

self.forum = [forum alloc]init];

你调用这样的方法,[self.forum backToLastPage];

而不是[self backToLastPage];