2011-10-11 24 views
3

我一直在努力弄清楚Spotify如何在應用程序進入離線模式時創建UI。他們看起來像StatusBar已調整大小,但實際上他們只是在下面放置一個視圖,並在整個應用程序中調整所有控制器的大小。我已經嘗試子類UINavigationController,子類UIWindow,調整窗口大小,但似乎沒有任何案件的工作。如何在Spotify iOS應用程序中模仿可調整大小的StatusBar

有關Spotify應用有趣的是,他們的解決方案似乎在iOS的」自己UIViewController子類模態呈現(如下圖所示,顯示出蘋果的MFMailComposeViewController還在努力 - 你可以告訴它不是一個自定義的控制器,因爲的UIBarButtonItems)。

如果任何人有任何洞察,如何這是可能的,那將是很棒的。

Spotify iOS app

回答

0

這是一件非常危險的事情。我過去做過,而且做過噩夢。在iOS4下工作的代碼下方,支持方向更改。

- (void) _adjustViewControllerforTicker { 
    TickerView* vv = [ApplicationContext getTickerView]; 
    if ([PreferenceDataModel isFxTickerOn]&& self.navigationController.view.frame.origin.y==0) { 

    CGRect tableRect = self.tableView.frame; 
    self.tableView.frame = CGRectMake(tableRect.origin.x,tableRect.origin.y, tableRect.size.width, tableRect.size.height -20); 
    UINavigationController *nav = self.navigationController; 
    CGRect gframe = CGRectOffset(self.navigationController.view.frame, 0, 20); 
    self.navigationController.view.frame = gframe; 
    if (!vv) { 
     vv = [[TickerView alloc] initWithFrame:CGRectMake(0, 0, 480, 20)]; 

     [nav.view addSubview:vv]; 
     [vv release]; 
     self.tableView.contentInset=UIEdgeInsetsMake(0,0,20.0,0.0); 
     [ApplicationContext setTickerView:vv]; 
    } 

    if (![PreferenceDataModel isTickerOn]) { 
     self.tableView.contentInset= UIEdgeInsetsZero; 
     if (vv){ 
      [vv removeFromSuperview]; 
      vv=nil; 
      [ApplicationContext setTickerView:nil]; 
    } 
} 

- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation   { 
    [self _adjustViewControllerforTicker]; 
} 

- (void) viewDidAppear:(BOOL)animated { 
    [super viewDidAppear:animated]; 
    [self _adjustViewControllerforTicker]; 
    TickerView* vv = [ApplicationContext getTickerView]; 
    if ([vv count]) { 
    [vv startAnimation]; 
    } 
} 

- (void)viewWillAppear:(BOOL)animated { 
    [super viewWillAppear:animated]; 
    [self _adjustViewControllerforTicker]; 
} 

,這是它的外觀:

enter image description here

+0

我很好奇,如果你的「股票」依然坐在上面的一切,當你提出一個模式的viewController?我已經嘗試過你正在做的事(調整NavigationController的視圖)。 – Sahil

+0

我的代碼是在UINavigationController級別添加的,所以即使在切換UIViewControllers時它也會保留。你可以用同樣的方式調整你的模態uiViewController,所以你會得到想要的效果。 – bioffe

+0

你能詳細說明一下「惡夢」嗎? – pablasso

相關問題