iOS Programming: The Big Nerd Ranch Guide阅读笔记(7)
Setting a view controller as the rootViewController of a window adds that view controller’s view as a subview of the window (Figure 7.4). It also automatically resizes the view to be the same size as the window. Given what you learned in Chapter 6, you could write setRootViewController: yourself:
- (void)setRootViewController:(UIViewController *)vc {
// Get the view of the root view controller UIView *rootView = [vc view];
// Make a frame that fits the window‘s bounds CGRect viewFrame =
[self bounds];
[rootView setFrame:viewFrame];
// Insert this view as window‘s subview
[self addSubview:rootView]; }
(This method does are a few more things, but this is what we are interested in right now).
郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。