Iphone-UIToolbar自动定位

Iphone-UIToolbar自动定位,iphone,iphone-sdk-3.0,Iphone,Iphone Sdk 3.0,我有一个应用程序,其中一个UIToolBar将一直位于屏幕的底部。无论设备方向如何 工具栏必须具有相同的屏幕宽度,并且始终对齐底部 如果设备旋转,工具栏必须采用新的宽度,并继续在底部对齐 有没有一种方法可以通过编程实现 谢谢你的帮助。是的。看看自动调整大小的遮罩。首先,自动旋转可能有点棘手。例如,如果您使用的是UITabBarController,则需要对其进行子类化并添加适当的委托方法。你应该先通过Apple docs和Google阅读auto rotation,然后才能真正投入其中 不过,为

我有一个应用程序,其中一个UIToolBar将一直位于屏幕的底部。无论设备方向如何

工具栏必须具有相同的屏幕宽度,并且始终对齐底部

如果设备旋转,工具栏必须采用新的宽度,并继续在底部对齐

有没有一种方法可以通过编程实现


谢谢你的帮助。

是的。看看自动调整大小的遮罩。

首先,自动旋转可能有点棘手。例如,如果您使用的是UITabBarController,则需要对其进行子类化并添加适当的委托方法。你应该先通过Apple docs和Google阅读auto rotation,然后才能真正投入其中

不过,为了明确回答您的问题,您需要如何声明UIToolbar,以便在安装应用程序时自动旋转它:

// I keep this definition in a file called constants.h since I use it a lot
#define SCREEN_FRAME [[UIScreen mainScreen] applicationFrame]

UIToolbar *tb = [[[UIToolbar alloc]init]autorelease];
// this frame will position a toolbar at the bottom of the screen
tb.frame = CGRectMake(0,
            SCREEN_FRAME.size.height-tb.frame.size.height,
            SCREEN_FRAME.size.width, 
            tb.frame.size.height);
//Setting the auto-resizing mask will make the toolbar resize when the viewController 
//it resides in rotates.
tb.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;

使用导航控制器,并使用