2013-10-08 51 views
1

所以我對xCode非常陌生,如果有人可以幫助我這麼做,它會有所幫助!'forum'沒有可見的@interface聲明選擇器'backToLastPage'

我正在創建一個非常簡單的應用程序。我有一個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 

回答

0

我覺得forum.h是單獨的類,backToLastPage方法是在該類中聲明的。

@property (nonatomic, strong) forum *forum; 

您需要創建該類分配,

self.forum = [forum alloc]init]; 

,並調用這樣的方法,[self.forum backToLastPage];

,而不是這個,[self backToLastPage];

+0

我在哪裏,我想發佈 self.forum = [forum alloc] init]; ? – user2620344

+0

in viewDidLoad方法 – karthika

+0

我只是複製並過去它,或者我需要其他任何東西嗎?我試圖複製粘貼它,它給了我錯誤。 – user2620344

相關問題