I am just looking at setting up a simple viewController programatically, I have a ViewController.xib file that I have set the background color to RED in interface builder. I have also开发者_如何学运维 added the following to my AppDelegate.m
@implementation syntax_MapViewAppDelegate
@synthesize window;
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
viewController = [[MapViewController alloc] init];
[window addSubview:[viewController view]];
[window makeKeyAndVisible];
return YES;
}
-(void)dealloc {
[viewController release];
[window release];
[super dealloc];
}
@end
When I run the code it does what I expect apart from the white bar at the bottom of the screen, can anyone give me any pointers in how to remove this? I have a feeling I might need to position the view within the window, but I am not sure how?
cheers Gary
Please set your view frame.
viewController.view.frame = CGRectMake(0.0,20.0,320.0,460.0);
Now the view cover your full screen with Red color.
You can also set it from interface builder as well.
Something like this might save your problem:
[[viewController view] setFrame:CGRectMake(0, 20, 320, 460)];
Set your view to resize dynamically using the autoresizingMask or set it's frame explicitly.
精彩评论