1

現在、「時刻表」を持つ IPhone アプリを使用しています。ポートレートでは、カスタマイズした通常のテーブルビューが必要です! IPhone を横向きにすると、テーブルと行を使用して、より「タイムテーブル」ビューに変更したいと考えています。

出来ますか?

4

3 に答える 3

2

これを試して

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {


    [self adjustViewsForOrientation:toInterfaceOrientation];

}

-(void) adjustViewsForOrientation:(UIInterfaceOrientation)orientation
{
    if (orientation == UIInterfaceOrientationPortrait || orientation == UIInterfaceOrientationPortraitUpsideDown)
    {
        //write code for portrait mode
    }
    else if (orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
    {
       //write code for landscape mode


    }
}
于 2013-01-14T10:00:54.913 に答える
1

Apples のドキュメントを参照してください。代替ランドスケープ インターフェイスの作成

必ずドキュメントを読んでください。ただし、実装例のコードは次のとおりです。

@implementation PortraitViewController
- (void)awakeFromNib
{
    isShowingLandscapeView = NO;
    [[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
    [[NSNotificationCenter defaultCenter] addObserver:self
                                 selector:@selector(orientationChanged:)
                                 name:UIDeviceOrientationDidChangeNotification
                                 object:nil];
}

- (void)orientationChanged:(NSNotification *)notification
{
    UIDeviceOrientation deviceOrientation = [UIDevice currentDevice].orientation;
    if (UIDeviceOrientationIsLandscape(deviceOrientation) &&
        !isShowingLandscapeView)
    {
        [self performSegueWithIdentifier:@"DisplayAlternateView" sender:self];
        isShowingLandscapeView = YES;
    }
    else if (UIDeviceOrientationIsPortrait(deviceOrientation) &&
             isShowingLandscapeView)
    {
        [self dismissViewControllerAnimated:YES completion:nil];
        isShowingLandscapeView = NO;
    }
}
于 2013-01-14T09:06:46.990 に答える
0

答えは「はい」です。次の方法で可能です。

- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
if(UIInterfaceOrientationIsLandscape(toInterfaceOrientation)){
\\ your timetable customisation goes here
     }
}

これも必要です:

    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
       return YES;
    }
于 2013-01-14T09:10:51.727 に答える