2016-03-04 21 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/"]]]; 
    }