我有一個應用程序,UIToolBar將不斷地在屏幕的底部。不管設備的方向如何。Iphone - UIToolbar自動位置
工具欄必須具有相同的屏幕寬度,並始終對底部進行調整。
如果設備旋轉,工具欄必須採用新的寬度並繼續在底部對齊。
有沒有辦法做到這一點編程?
感謝您的任何幫助。
我有一個應用程序,UIToolBar將不斷地在屏幕的底部。不管設備的方向如何。Iphone - UIToolbar自動位置
工具欄必須具有相同的屏幕寬度,並始終對底部進行調整。
如果設備旋轉,工具欄必須採用新的寬度並繼續在底部對齊。
有沒有辦法做到這一點編程?
感謝您的任何幫助。
首先,自動旋轉可能有點棘手。例如,如果您使用的是UITabBarController,則需要對其進行子類化並添加適當的委託方法。您應該在通過Apple文檔和Google自動旋轉之前閱讀,然後才能真正潛入。
要專門回答您的問題,以下是您需要聲明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;
是的。看看自動調整口罩。
使用導航控制器,並利用toolbarItems
property的。
在iOS6上,init後的tb.frame是{{0,0},{0,0}} ... – Josejulio 2013-05-25 16:01:21