2011-03-21 37 views
2

我是Objective-C的新手,我正在开发一个webradio应用程序。在应用程序中的任何位置的持久视图

我的应用程序由TabBarController中包含的一些NavigationControllers组成。

我想做一个视图,这将保持在TabBar所有的时间上方。 (它将包含音频播放器控件,并且必须可在应用程序的任何位置访问)

这样做的最佳方式是什么?

谢谢!

SQ,P

回答

2

您需要添加视图作为UITabBarController视图属性的子视图:

m_yourToolbar =[[UIToolbar alloc] initWithFrame:CGRectMake(0, 401, 320, 44)]; 
// set some properties on the toolbar 
// ... 
[self.tabBarController.view m_yourToolbar]; 

这增加了的UILabel嗒嗒在为所述的UITabBarController每个选项卡中的内容(m_tabBarController) 。

@interface YouAppDelegate : NSObject <UIApplicationDelegate, UITabBarControllerDelegate> { 
    UIToolbar * m_yourToolbar; 

    // ... whatever other stuff you have in your app delegate 
} 

@property (nonatomic, retain) UIToolbar * yourToolbar; 

在你的应用程序代理实现,你将需要:

@synthesize yourToolbar= m_yourToolbar; 
// .. other app delegate stuff 

所以在需要更新工具栏视图控制器,你可以得到应用程序委托的保持,抢yourToolbar属性和设置属性:

AppDelegate *appDelegate = (YouAppDelegate *)[[UIApplication sharedApplication] delegate]; 
// set stuff on the toolbar property 
appDelegate.yourToolbar.stuff = stuff; 
+0

+1这是非常普遍的,特别是如果你希望广告出现在整个应用程序。 AdWhirl建议这个确切的事情。 – 2011-03-21 20:18:48

+0

谢谢,我会尝试。但是,实现UITabBarController的最好方法是什么(在XCode模板中没有.h&.m文件,tabBarController在appDelegate中声明) – 2011-03-21 20:47:37

+0

您不需要实现UITabBarController。你只需要访问在appDelegate中声明的tabBarController(所以只需在你的appDelegate代码中用self.tabBarController代替m_tabBarController)。 – RedBlueThing 2011-03-21 22:31:39

相关问题