我正在制作 iPad 应用程序
我只将所有东西的框架设置为纵向
但我也想要风景的方向
在 appTarget 我选择所有支持的界面方向。
在纵向模式下它工作得很好但是当我在横向模式下移动它时
然后我的视图和我的所有控件都乱了,看起来很糟糕
你能告诉我如何管理所有的方向吗
请简单详细地告诉我
我正在制作 iPad 应用程序
我只将所有东西的框架设置为纵向
但我也想要风景的方向
在 appTarget 我选择所有支持的界面方向。
在纵向模式下它工作得很好但是当我在横向模式下移动它时
然后我的视图和我的所有控件都乱了,看起来很糟糕
你能告诉我如何管理所有的方向吗
请简单详细地告诉我
将此添加到您的 AppDelegate.m 文件中以支持两个方向。
- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window
{
return (UIInterfaceOrientationMaskAll);
}
试试这个.....假设你的 ipad 底部有一个按钮。那么如何在横向和纵向模式下将其放在同一位置...
-(NSUInteger)supportedInterfaceOrientations
{
if ([[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortrait||[[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortraitUpsideDown) {
pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
}
else
{
pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
}
return (UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscapeLeft|UIInterfaceOrientationMaskLandscapeRight|UIInterfaceOrientationMaskPortraitUpsideDown);
}
-(BOOL)shouldAutorotate
{
return YES;
}
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
if ([[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortrait||[[UIApplication sharedApplication] statusBarOrientation]==UIInterfaceOrientationMaskPortraitUpsideDown) {
pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
}
else
{
pButton.frame=CGRectMake(self.view.frame.size.width-70, self.view.frame.size.height-70, 70, 70);
}
return YES;
}
看到您必须覆盖这些方法以在两种模式下调整您的 gui,并且您必须在这些方法中调整您的 GUI 元素的框架。. .