gpt4 book ai didi

ios - 如何将标签栏 Controller 作为 subview 添加到父 View ?

转载 作者:行者123 更新时间:2023-12-01 16:33:53 29 4
gpt4 key购买 nike

- (void)viewDidLoad 
{
[super viewDidLoad];

UITabBarController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"tabbar"];
[self addChildViewController:controller];
controller.view.frame = CGRectMake(0,0, 500, 500);
[self.view addSubview:controller.view];
[controller didMoveToParentViewController:self];
}

如何在 objective-C 中将 tabbar viewcontroller 作为 subview 添加到 uiviewcontroller?

最佳答案

正如已经提到的,您已经在此处执行此操作 [self.view addSubview:controller.view]

标签栏 Controller View 的自动调整大小掩码采用其父 View 的完整大小。

如果在实例化标签栏 Controller 时设置框架,请务必更改标签栏 View 的 autoresizingMask 属性,使其不具有灵活的宽度或灵活的右边距。

关于ios - 如何将标签栏 Controller 作为 subview 添加到父 View ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29937435/

29 4 0