视图控制器.m
//
// ViewController.m
// WebViewDemo
//
// Created by Vu Van Tiep on 1/15/13.
// Copyright (c) 2013 Vu Van Tiep. All rights reserved.
//
#import "ViewController.h"
#import "WebViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([[segue identifier] isEqualToString:@"GoogleSegue"]){
WebViewController *desView = (WebViewController*) [segue destinationViewController];
UIWebView *webView = desView.webView;
if([webView respondsToSelector:@selector(loadRequest:)] || webView != nil){
UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"title" message:@"message" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
[alert show];
}
//webView is nil
}
}
@end
WebViewController.m
//
// WebViewController.m
// WebViewDemo
//
// Created by Vu Van Tiep on 1/15/13.
// Copyright (c) 2013 Vu Van Tiep. All rights reserved.
//
#import "WebViewController.h"
@interface WebViewController ()
@end
@implementation WebViewController
@synthesize webView;
- (void)viewDidLoad
{
[super viewDidLoad];
self.webView.scalesPageToFit = YES;
}
@end
WebViewController.h
@interface WebViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *webView;
@end
当我使用 [segue destinationViewController] 时,我得到了 WebViewController 对象,但是当我访问该对象的 webView 属性时,它是 nil
有人可以向我解释一下吗?:(
谢谢!