I am interested in developing a Three20 based application for iPhone OS that is primarily landscape oriented.
I downloaded the Three20 sample project templates, loaded them in Xcode, and started the sample project app fine in the simulator and on the device using the 3.0, 3.1, 3.1.2 SDK. When I changed the Initial interface orientation
to Landscape (right home button)
in the project's Info.plist
file, the project started in that orientation as expected, but only responded to touch eve开发者_如何学Gonts on left-hand side of the screen. It appears as if it is still responding to touch events as if it is still in portrait mode. The only change I've made to the sample project is changing the Info.plist
file.
Am I missing something very simple? Starting in landscape orientation seems to be a very basic use case - but I can't find anyone else who's filed an issue report or blog post on it after googling around for a couple of days.
Note: This is a problem I encountered originally in a much more advanced project while introducing landscape orientation, but I backed up to the most basic repeatable example to rule out any other code as the source of the problem.
Make sure that all views have the correct autoresizingMask
property set. As most views do not clip to bounds, content is also visible beyond the bounds of the parentView. Touches however are alway clipped to bounds, which could lead to childViews being visible out side of the bounds of the parentView, but not being touchable.
Ergo: if a parent view does not fit the new width, the right part of the screen might be rendered with content that is not touchable.
Are you using a specific view? It could be as simple as needing to add:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
To your view controller.
- (void)viewWillAppear:(BOOL)animated
{
if (![System isIpad])
{
if (([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortrait) ||
([[UIDevice currentDevice] orientation] == UIInterfaceOrientationPortraitUpsideDown))
{
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationLandscapeRight];
}
}
[super viewWillAppear:animated];
// self.navigationController.navigationBar.barStyle = UIBarStyleBlackOpaque;
// self.navigationBarTintColor = [UIColor clearColor];
self.navigationController.navigationBarHidden = YES;
[[UIApplication sharedApplication] setStatusBarHidden:FALSE];
}
精彩评论