I have a simple web-application that im using native to build.
My application consicts of MainWindow.xlb with is filled with Native View Controller.
Within Native View Controller.m i have the following code:
http://pastebin.com/xXFc0JCW
Looked to messy to copy and paste in here.
I cant seem to understand where i'm going wrong and why my application/ UIWebView always stays portrait.
Im new to iOS development.
Full source code: https://www.dropbox.com/s/i9woti5ptecr9n4/Native.zip
Now it works:
NativeAppDelegate.m
#import "NativeAppDelegate.h"
#import "NativeViewController.h"
@implementation NativeAppDelegate
@synthesize window;
@synthesize viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after app launch
[self.window setRootViewController:viewController];
return YES;
}
- (void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
@end
NativeViewController.m
#import "NativeViewController.h"
@implementation NativeViewController
@synthesize webView;
// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
[super viewDidLoad];
NSString *filePath = [[NSBundle mainBundle] pathForResource:@"login" ofType:@"html"];
NSData *htmlData = [NSData dataWithContentsOfFile:filePath];
if (htmlData) {
NSBundle *bundle = [NSBundle mainBundle];
NSString *path = [bundle bundlePath];
NSString *fullPath = [NSBundle pathForResource:@"login" ofType:@"html" inDirectory:path];
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL fileURLWithPath:fullPath]]];
}
}
- (void)didReceiveMemoryWarning {
// Releases the view if it doesn't have a superview.
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
- (void)viewDidUnload {
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)dealloc {
[webView release];
[super dealloc];
}
@end
And I also unchecked ScaleToFill in the WebView in InterfaceBuilder otherwise you had to scroll the page to see your hello world.
I removed the Methods for orientation and set the RootviewController for your Window to your ViewController. Your window did not have a RootVieController.
Frankly, I do not see any problem within your code sniplets. However, there has been a change recently, intoduced with iOS6. If I am not much mistaken then shouldRotateToInterfaceOrientation will not be called anymore for apps build with the current SDK. Instead of that you define the supported interface orientation in info.plist and may overwrite that setting in your view controller by overwriting the method supportedInterfaceOirentations wich returns a bitmask in an integer (how modern ... :)
From the Docs:
Handling View Rotations In iOS 6, your app supports the interface
orientations defined in your app’s Info.plist file. A view controller
can override the supportedInterfaceOrientations method to limit the
list of supported orientations. Generally, the system calls this
method only on the root view controller of the window or a view
controller presented to fill the entire screen; child view controllers
use the portion of the window provided for them by their parent view
controller and no longer participate in directly in decisions about
what rotations are supported. The intersection of the app’s
orientation mask and the view controller’s orientation mask is used to
determine which orientations a view controller can be rotated into.
Please correct me if I am wrong here.