我想将 UIViewController 中的现有视图更改为新视图。新视图包含旧视图和一个小横幅视图。
做这个相当简单的改变给我留下了一个黑色的看法。
我的代码看起来像这样
UIView *existingView = self.view;
UIView *newView = [[UIView alloc] initWithFrame:existingView.frame];
UIView *bannerView = [[UIView alloc] initWithFrame:CGRectMake(0, (self.view.frame.size.height - 50), 320, 50)];
CGRect existingViewFrame = existingView.frame;
existingViewFrame.size.height -= 50;
existingView.frame = existingViewFrame;
[newView addSubview:existingView];
[newView addSubview:bannerView];
self.view = newView;
但是,当切换选项卡并返回到更改视图的视图时,会像我想要的那样显示。我想我需要设置一个标志或其他东西来告诉控制器重绘它的(新)视图。
编辑
我为这个问题写了一个简单的例子。你可以在 GitHub 上找到它:https ://github.com/Oemera/ChangeView