我刚刚添加了一个新的 UIWebView,但它似乎没有出现。我在这里很新,所以这可能是一个非常简单的错误。
我使用情节提要创建了视图并将其拖到我的 GuideViewController.h
这是我的 GuideViewController.h
#import <UIKit/UIKit.h>
@interface GuideViewController : UIViewController
@property (weak, nonatomic) IBOutlet UIWebView *newsWebView;
@end
这是我的 GuideViewController.m
#import "GuideViewController.h"
@interface GuideViewController ()
@end
@implementation GuideViewController
@synthesize newsWebView;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
NSURL *newsURL = [NSURL URLWithString:@"http://www.yahoo.com"];
NSURLRequest *newsRequest = [NSURLRequest requestWithURL:newsURL];
[newsWebView loadRequest:newsRequest];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
这就是我用来将视图添加到我的应用程序委托的方法。我已经添加了侧边栏菜单。
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
VidViewController *vidViewController = [[VidViewController alloc] init];
GuideViewController *newsWebView = [[GuideViewController alloc] init];
UINavigationController *navController1 = [[UINavigationController alloc] initWithRootViewController:vidViewController];
[self.window setRootViewController:navController1];
SelectVideo1 *selectVideo1 = [[SelectVideo1 alloc] initWith:@"Test"];
//[self.navController pushViewController:selectVideo1 animated:YES];
SelectVideo1 *selectVideo2 = [[SelectVideo1 alloc] initWith:@"Latest News"];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
UIStoryboard *tabStoryBoard = [UIStoryboard storyboardWithName:@"TabStoryboard" bundle:nil];
UIStoryboard *navStoryBoard = [UIStoryboard storyboardWithName:@"NavStoryboard" bundle:nil];
UINavigationController *navController = [navStoryBoard instantiateViewControllerWithIdentifier:@"Nav Controller"];
UITabBarController *tabController = [tabStoryBoard instantiateViewControllerWithIdentifier:@"Tab Controller"];
ViewController *redVC, *greenVC;
redVC = [[ViewController alloc] init];
greenVC = [[ViewController alloc] init];
RootController *menuController = [[RootController alloc]
initWithViewControllers:@[navController, selectVideo1, selectVideo2, tabController, newsWebView]
andMenuTitles:@[@"Test", @"Videos", @"Latest News", @"Walkthroughs", @"Official News"]];
self.window.rootViewController = menuController;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
@end
该视图显示在菜单栏中,但是当我单击它时,什么也没有发生。我相信问题在于我的 appdelegate 以及我如何调用视图?