我使用tableview與搜索欄顯示控制器,它顯示良好的縱向和橫向視圖,但是從橫向到縱向搜索欄大小減少,如何更改原始大小當從橫向到縱向改變方向時,縱向滑塊寬度減小
0
A
回答
0
首先你應該抓住定位:
//AppDelegate.h
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (nonatomic, unsafe_unretained) NSInteger isPortrait;
//AppDelegate.m
@synthesize isPortrait;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
isPortrait = 1;
}
執行狀態:後旋轉爲橫向模式顯示正確的寬度和回波泰特寬度後
-(void)viewWillAppear:(BOOL)animated{
[[UIApplication sharedApplication] statusBarOrientation];
[[UIDevice currentDevice] orientation];
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(deviceRotated:) name:UIDeviceOrientationDidChangeNotification object:nil];
}
//methode deviceRotated
-(void)deviceRotated:(NSNotification*)notification{
AppDelegate *app = (AppDelegate *)[UIApplication sharedApplication].delegate;
UIInterfaceOrientation orientation = [[UIApplication sharedApplication] statusBarOrientation];
if(orientation == UIInterfaceOrientationLandscapeLeft || orientation == UIInterfaceOrientationLandscapeRight)
{
[self searchBarLandscape];
app.isPortrait = NO;
}
else{
[self searchBarPortrait];
app.isPortrait = YES;
}
}
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
return YES;
}
- (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication].delegate;
if (toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown || toInterfaceOrientation == UIInterfaceOrientationPortrait)
{
app.isPortrait = 1;
}
else if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft || toInterfaceOrientation == UIInterfaceOrientationLandscapeRight)
{
app.isPortrait = 0;
}
[self prepareSearchBarOrientation];
}
-(void)prepareSearchBarOrientation
{
AppDelegate * app = (AppDelegate *)[UIApplication sharedApplication].delegate;
if (app.isPortrait)
{
[self searchBarPortrait];//Set Frame here
}
else
{
[self searchBarLandscape];
}
}
0
相關問題
- 1. popViewControllerAnimated:從橫向到縱向
- 2. iphone:從縱向到橫向
- 3. UITableView在從縱向,橫向,縱向旋轉時更改尺寸
- 4. 縱向滑塊(jQuery)
- 5. 方向縱向和橫向模式
- 6. 當方向從縱向變爲橫向時,視頻從Android開始開始?
- 7. 從縱向到橫向的TabBar旋轉
- 8. 保存HTML字體大小時,iPhone方向從縱向變爲橫向
- 9. 將元素的方向從縱向更改爲橫向
- 10. 動態改變縱/橫方向
- 11. 更改科科斯二維方向在橫向到縱向
- 12. 使用橫向和縱向的滑動滑塊
- 13. 維持橫向/縱向
- 14. NavigationController橫向和縱向
- 15. 複選框從縱向到橫向模式的句柄方向
- 16. Android切換VideoView方向從縱向到橫向而不橫向拉伸視頻
- 17. Android的橫向/縱向變化difficults
- 18. Android:如何處理縱向反轉縱向和橫向反轉橫向事件
- 19. 如何更改縱向和橫向的模擬器方向?
- 20. iOS5的位置固定:移動改變方向在橫向到縱向
- 21. Android應用程序強制關閉改變縱向到橫向
- 22. Android:在活動啓動時獲取方向(橫向/縱向)
- 23. iOS在縱向時會返回橫向方向
- 24. 如何以橫向適應縱向圖像在縱橫比保持縱橫比
- 25. 如何將Reveal.js方向更改爲縱向或縱向?
- 26. Android:從縱向轉向橫向時定位按鈕
- 27. 獲得當移動交換從縱向到橫向和反轉
- 28. 當我將縱向從縱向改爲橫向時,我的計算結果正在消失。如何解決它?
- 29. 如何在從縱向旋轉到橫向時更改UIBarButtonItem大小?
- 30. 以編程方式將方向從橫向改爲縱向模式xamarin IOS
當從風景旋轉到縱向時,請讓我看看問題的圖像。 – Sovannarith 2013-05-02 06:38:03
我上面的方法可以幫助你,請試試我的代碼。 – Sovannarith 2013-05-02 06:49:58
感謝您的幫助 – sabeer 2013-05-02 12:26:58