iphone - 将 subview 添加到 AppDelegate

标签 iphone subview addsubview

我想向 AppDelegate 添加两个 subview ,一个用于 mainviewController,另一个用于 UIToolbar subview 。

 - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]autorelease];
// Override point for customization after application launch.
self.mainViewController = [[[MainViewController alloc]init]autorelease];
self.window.rootViewController = self.mainViewController;
[self.window makeKeyAndVisible];
return YES;
}

最佳答案

只需将其添加到应用程序委托(delegate)的窗口(我建议以相同的方式显示 rootViewController 以支持 iOs 3):

[self.window addSubview:myToolBar];
[self.window addSubview:self.mainViewController.view];

请注意,在顶部 viewController 上使用一些动画不会为工具栏设置动画,因为在这种情况下它不是此 viewController 的 View subview 。

关于iphone - 将 subview 添加到 AppDelegate,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10675413/

相关文章:

iphone - 如何为 iPhone 应用程序中的“设置”应用程序指定图像

iphone - 如何在同一个 iPhone View 上拥有表格和其他元素?

iphone - 插入 subview :belowSubview: for a UIImageView

ios - 从 subview 更新主视图上的 IBOutlet

ios - 执行多个sqlite3_exec,不创建表,为什么?

iphone - ARC 语义问题 : No Visible @Interface for 'UIViewController' declares the selector 'loginResult:'

iphone - 如何正确释放 AVCaptureSession

iphone - UIView subview 中的 IOS UIImagePicker

iPhone subview 的位置?

objective-c - 如何让一个 subview 填充它的父 View