1

我在 splitview 应用程序的 DetailView.m 中使用此代码。现在方向变化仅在设备旋转时发生。启动应用程序时不会进行检测。我也收到此警告

警告:“RootViewController”可能不会响应“-adjustViewsForOrientation:”

启动应用程序时,我需要进行哪些更改才能使应用程序调整方向代码。

> - (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
> duration:(NSTimeInterval)duration {
>     [self adjustViewsForOrientation:toInterfaceOrientation];
> }
> 
> - (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation
> {
>     if (orientation == UIInterfaceOrientationLandscapeLeft ||
> orientation ==
> UIInterfaceOrientationLandscapeRight)
> {
>         detailDescriptionLabel.center = CGPointMake(235.0f, 42.0f);
>         bigthumbImageView.center = CGPointMake(355.0f, 70.0f);
>         
>     }
>     else if (orientation == UIInterfaceOrientationPortrait ||
> orientation ==
> UIInterfaceOrientationPortraitUpsideDown)
> {
>         detailDescriptionLabel.center = CGPointMake(160.0f, 52.0f);
>         bigthumbImageView.center = CGPointMake(275.0f, 80.0f);
>         
>     } }
4

2 回答 2

1

您需要在 RootViewController.h 中声明您的方法,如下所示:

- (void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation;

否则你会收到警告。为了确保您的视图在应用程序启动时旋转,请在 applicationDidFinishLaunching 方法的 AppDelegate 类中添加对 adjustViewsForOrientation 的调用。

于 2010-05-13T10:15:52.907 回答
1
于 2010-05-13T10:18:38.367 回答