Created
August 8, 2012 08:20
-
-
Save hanse/3293379 to your computer and use it in GitHub Desktop.
tomarild @ mac1.no
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface AppDelegate : UIResponder <UIApplicationDelegate, UITabBarControllerDelegate> | |
@property (strong, nonatomic) UITabBarController *tabBarController; | |
@property (strong, nonatomic) UIWindow *window; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "AppDelegate.h" | |
#import "MyWebViewController.h" | |
@implementation AppDelegate | |
@synthesize window = _window; | |
@synthesize tabBarController = _tabBarController; | |
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions | |
{ | |
_window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; | |
_tabBarController = [[UITabBarController alloc] init]; | |
_tabBarController.view.frame = CGRectMake(0, 0, 320, 460); | |
_tabBarController.viewControllers = [NSArray arrayWithObjects: | |
[[MyWebViewController alloc] initWithURL:@"http://vg.no"], | |
[[MyWebViewController alloc] initWithURL:@"http://db.no"] | |
, nil]; | |
[_window addSubview:_tabBarController.view]; | |
[_window makeKeyAndVisible]; | |
return YES; | |
} | |
- (void)applicationWillResignActive:(UIApplication *)application | |
{ | |
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. | |
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. | |
} | |
- (void)applicationDidEnterBackground:(UIApplication *)application | |
{ | |
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. | |
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. | |
} | |
- (void)applicationWillEnterForeground:(UIApplication *)application | |
{ | |
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. | |
} | |
- (void)applicationDidBecomeActive:(UIApplication *)application | |
{ | |
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. | |
} | |
- (void)applicationWillTerminate:(UIApplication *)application | |
{ | |
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. | |
} | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <UIKit/UIKit.h> | |
@interface MyWebViewController : UIViewController | |
@property (nonatomic, strong) UIWebView *webView; | |
@property (nonatomic, copy) NSString *urlAddress; | |
-(id)initWithURL:(NSString *)url; | |
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import "MyWebViewController.h" | |
@interface MyWebViewController () | |
@end | |
@implementation MyWebViewController | |
@synthesize webView = _webView; | |
@synthesize urlAddress = _urlAddress; | |
- (id)initWithURL:(NSString *)urlAddress { | |
if (self = [super init]) { | |
_urlAddress = urlAddress; | |
} | |
return self; | |
} | |
- (void)viewDidLoad { | |
NSURL *url = [NSURL URLWithString:_urlAddress]; | |
NSURLRequest *request = [NSURLRequest requestWithURL:url]; | |
_webView = [[UIWebView alloc] initWithFrame:self.view.bounds]; | |
[_webView loadRequest:request]; | |
[self.view addSubview:_webView]; | |
} | |
- (void)viewDidUnload | |
{ | |
[super viewDidUnload]; | |
// Release any retained subviews of the main view. | |
} | |
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation | |
{ | |
return (interfaceOrientation == UIInterfaceOrientationPortrait); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment