Hello,
I'm developing "landscape mode-only" app for an iPad. Problem is that my views have wrong positions on the screen, and I can't find the reason...
I've set necessary properties in the Info.plist:
<key>UIInterfaceOrientation</key>
<string>UIInterfaceOrientationLandscapeRight</string>
<key>UISupportedInterfaceOrientations</key>
<array>
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
I have hierarchy like that:
UIWindow --> MainMenuViewController.view --> MyTableviewController.view
In AppDelegate's application:didFinishLaunchingWithOptions:
method I have this code:
CGRect rect = [[UIScreen mainScreen] bounds];
[window setBounds:rect];
mainMenuController = [[MainMenuViewController alloc] init];
[window addSubview:mainMenuController.view];
[window makeKeyAndVisible];
return YES;
In MyMenuController's viewDidload:
I have that:
[super viewDidLoad];
[[UIApplication sharedApplication] setStatusBarHidden:YES];
SelectPictureTableViewController *selectPictureViewController = [[SelectPictureTableViewController alloc] initWithStyle:UITableViewStylePlain];
[selectPictureViewController.view setBounds:CGRectMake(0.0, 128.0, 1024.0, 640.0)];
[self.view addSubview:selectPictureViewController.view];
In SelectPictureTableViewController's initWithStyle:
I wrote that:
if ((self = [super initWithStyle:style])) {
templatesArray = [[NSMutableArray alloc] init];
tumbnailsInRow = 3;
self.tableView.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"bg.png"]];
self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
self.tableView.allowsSelection = NO;
}
return self;
In both ViewControllers I have this implementation:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (interfaceOrientation != UIInterfaceOrientationPortrait &&
interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
For me it looks like it should display 1024x640 table view. But it displays tableview with height about 350px and shifted to the middle of the screen (about 250px from the top). Do you have any ideas why it can be so shifted? Probably I have to set up bounds somewhere and forgot to do that? Stucked with this problem for few hours.
PS: Without MainMenuViewController position of the tableview was fine (when I added tableview as subView of the UIWindow). But I need to place other UI elements to the screen and I need this MainMenuViewController...
Cheers!