【发布时间】:2012-06-15 13:17:01
【问题描述】:
我用按钮和图像在风景模式下设计了我的笔尖,但在模拟器中它以横向模式显示,但按钮和图像不像笔尖上的那样,它们似乎在右侧而不是在最佳?请有任何指示。 笔尖图片
【问题讨论】:
-
您使用的是什么版本的 SDK 和 XCode?span>
我用按钮和图像在风景模式下设计了我的笔尖,但在模拟器中它以横向模式显示,但按钮和图像不像笔尖上的那样,它们似乎在右侧而不是在最佳?请有任何指示。 笔尖图片
【问题讨论】:
如果您希望此视图控制器被限制为在您的视图控制器类中使用某个方向
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
请在此处阅读我的答案Keep iPhone rotation in landscape?
【讨论】:
您在界面构建器中设计视图(纵向/横向)的方式不会影响其实际显示方式。您需要在代码中(或可能在 p 列表中)进行设置。
【讨论】:
使用此代码
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
NSLog(@"Landscape Mode");
// your code when your sdk is in landscape mode
}
else
{
NSLog(@"Portrait Mode");
// your code here
}
}
【讨论】: