所以我对 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