2016-03-04 19 views
-2

基本上正如标题所说,我有我的WebViewAppDelegate一些问题与截图后更改URL中的WebView问题已经采取

https://github.com/austin4195/Nucleus-iOS/blob/master/Classes/WebViewAppDelegate.m

线5-48,但我相信这个问题是用什么定义将存储该值的项目

谢谢!

+0

你有什么样的问题??? –

+0

大部分时间是让观察者存储一个值在下一部分中进行检查。 “如果用户使用屏幕截图,那么将网址更改为”其他任何“停留在网页上”类型的东西 –

回答

0

有很多的问题与您的代码:

  • 你要排队36 return语句,所以你的代码不会被调用。
  • screenshotTaken应宣布在application:didFinishLaunchingWithOptions:之外。
  • 您应该使用self.webViewController.theWebView而不是webViewController.webView

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {  
        navigationController = [[UINavigationController alloc] init]; 
        navigationController.navigationBar.hidden = YES; 
        navigationController.toolbar.barStyle = UIBarStyleBlack; 
        WebViewController *webViewController = [[WebViewController alloc] init]; 
        webViewController.urlString = @"http://files.austinapps.org/File%20Site"; 
        [navigationController pushViewController:webViewController animated:NO]; 
        [webViewController release]; 
        [self.window setRootViewController:navigationController]; 
        [self.window makeKeyAndVisible]; 
        self.webViewController = webViewController; 
        [[NSNotificationCenter defaultCenter] addObserver:self 
                  selector:@selector(screenshotTaken) 
                  name:UIApplicationUserDidTakeScreenshotNotification 
                  object:application]; 
        return YES; 
    } 
    
    - (void)screenshotTaken{ 
        [self.webViewController.theWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://website.com/"]]]; 
    }