Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/38.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 我想调整工具栏的大小_Iphone_Orientation - Fatal编程技术网

Iphone 我想调整工具栏的大小

Iphone 我想调整工具栏的大小,iphone,orientation,Iphone,Orientation,我想在方向改变时调整工具栏的大小。 但我面临着一个难题 我有两个视图控制器。 第一个视图控制器有一个按钮。当按下此按钮时,第二个视图将显示在显示屏上。这些视图控制器属于导航控制器 第一个视图控制器使导航栏显示。第二视图控制器使导航栏隐藏 第一视图控制器中的重要方法 } 第二视图控制器中的重要方法 第二个视图控制器中的rest方法类似于第一个视图控制器 在第一个视图控制器中启动纵向模式后,我按了下一步按钮。改变方向很好。 (第一个屏幕截图) 但是从第一个视图控制器中的纵向模式开始,我改为横向模

我想在方向改变时调整工具栏的大小。 但我面临着一个难题

我有两个视图控制器。 第一个视图控制器有一个按钮。当按下此按钮时,第二个视图将显示在显示屏上。这些视图控制器属于导航控制器

第一个视图控制器使导航栏显示。第二视图控制器使导航栏隐藏

第一视图控制器中的重要方法

}

第二视图控制器中的重要方法

第二个视图控制器中的rest方法类似于第一个视图控制器

在第一个视图控制器中启动纵向模式后,我按了下一步按钮。改变方向很好。 (第一个屏幕截图)

但是从第一个视图控制器中的纵向模式开始,我改为横向模式。 然后我按了下一个按钮,这使得布局很奇怪。 (第二个屏幕截图)

我不知道是什么造成了这个问题

请告诉我你的经历。你的建议会使我清醒的。
谢谢您的阅读。

代码看起来不太可能。。。。但是 您也可以尝试调整viewcontroller的ViewWillDisplay方法中的内容大小。
这可能会有帮助。

为什么不直接使用自动调整大小的遮罩呢?

我正在使用自动调整大小的遮罩。[工具栏设置自动重新设置任务:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleWidth | UIViewAutoResizingFlexibleToMargin | UIViewAutoresizingFlexibleTopMargin];
- ( void ) viewWillAppear: ( BOOL )animated {

      [ super viewWillAppear: animated ];
      [ [ [ self navigationController ] navigationBar ] setHidden: NO ];

      UIButton *nextButton;
      nextButton = [ UIButton buttonWithType: UIButtonTypeRoundedRect ];
      [ nextButton setFrame: CGRectMake( 50.0, 50.0, 200.0, 150.0 ) ];
      [ nextButton setTag: 100 ];
      [ nextButton addTarget: self action: @selector( touchedNextButton: ) forControlEvents: UIControlEventTouchUpInside ];
      [ [ self view ] addSubview: nextButton ];
}

- ( BOOL ) shouldAutorotateToInterfaceOrientation: ( UIInterfaceOrientation )interfaceOrientation {

   // Return YES for supported orientations
   BOOL iResult;
   iResult = ( ( interfaceOrientation == UIInterfaceOrientationPortrait ) || ( interfaceOrientation == UIInterfaceOrientationLandscapeLeft ) ||
                       ( interfaceOrientation == UIInterfaceOrientationLandscapeRight ) );
   return iResult;
    - ( void ) didRotateFromInterfaceOrientation: ( UIInterfaceOrientation )fromInterfaceOrientation {

        UIInterfaceOrientation orientation = [ [ UIDevice currentDevice ] orientation ];

        UIButton *button = ( UIButton * )[ [ self view ] viewWithTag: 100 ];

        switch ( orientation ) {
            case UIInterfaceOrientationPortrait:
                [ button setFrame: CGRectMake( 50.0, 50.0, 200.0, 150.0 ) ];
                break;
            case UIInterfaceOrientationLandscapeLeft:
            case UIInterfaceOrientationLandscapeRight:
                [ button setFrame: CGRectMake( 50.0, 50.0, 200.0, 150.0 ) ];
                break;
            default:
                break;
        }
    }
- ( void ) viewDidLoad {

    [ [ [ self navigationController ] navigationBar ] setHidden: YES ];

    UIImage *imageBackArrow_iPhone = [ UIImage nonCachedImageNamed: @"backArrow_iPhone.png" ];
    NSMutableArray *toolbarItems = [ [ NSMutableArray alloc ] initWithCapacity: 5 ];
    [ toolbarItems addObject: [ [ [ UIBarButtonItem alloc ] initWithImage: imageBackArrow_iPhone style: UIBarButtonItemStylePlain target: self
                                                                       action: @selector( touchedBackArrowButton ) ] autorelease ] ];
        UIToolbar *toolbar = [ [ UIToolbar alloc ] initWithFrame: CGRectMake( 0.0, 416.0, 320.0, 44.0 ) ];
        [ toolbar setAutoresizingMask: UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleHeight | UIViewAutoresizingFlexibleTopMargin ];
        [ toolbar setItems: toolbarItems ];
        [ toolbarItems release ];
        [ [ self view ] addSubview: toolbar ];
        [ toolbar release ];
    }
}