使用Phonegap添加自定义UIWebView

时间:2012-08-08 08:47:44

标签: ios cordova webview

我有一个iOS应用程序,需要对Facebook帐户进行OAuth身份验证,但我必须使用自己的服务器进行API调用。 因此,当点击某个按钮时,我想打开一个带有登录URL的FBLogin屏幕(UIWebView)。

我有以下代码:

FBWebViewController.h

#import <UIKit/UIKit.h>

@interface FBWebViewController : UIViewController <UIWebViewDelegate>
- (void)initFBWebView;
@end

FBWebViewController.m

- (void)initFBWebView {
NSLog(@"DetailViewController->initUIWebView {");

    UIWebView *aWebView;

    //  init and create the UIWebView
    aWebView = [[UIWebView alloc] initWithFrame:CGRectMake(0, 0, 320, 400)];
    aWebView.autoresizesSubviews = YES;
    aWebView.autoresizingMask=(UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleWidth);

    //set the web view delegates for the web view to be itself
    [aWebView setDelegate:self];

    //Set the URL to go to for your UIWebView
    NSString *urlAddress = @"http://www.google.com";

    //Create a URL object.
    NSURL *url = [NSURL URLWithString:urlAddress];

    //URL Requst Object
    NSURLRequest *requestObj = [NSURLRequest requestWithURL:url];

    //load the URL into the web view.
    [aWebView loadRequest:requestObj];

    //add the web view to the content view
    [self.view addSubview:aWebView];

}

并在我的Authorize.m文件中,该文件处理所有API调用等。

- (void)fbLogin:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
    FBWebViewController *webview = [[FBWebViewController alloc] init];
    [webview view];
    [webview initFBWebView];
}

什么都没发生。没有打开WebView。我在initWithFbWebView方法中放了一些调试语句,调用该方法并运行到最后,但没有显示任何屏幕。

我做错了什么?

0 个答案:

没有答案