当我现在开发的游戏中单击暂停按钮时,我必须使用 UIView 作为一种暂停 View 。 这个暂停 View 将在 40 个 UIViewController 中使用。我在 UI 中使用“ Storyboard”,但我在 .xib 文件中设计了暂停 View 。
如何在我的应用程序中加载和使用此 View ?如何加载 UIView?
最佳答案
您可以将此 View 添加到 View Controller 并使用 [yourView setEnabled:NO] 将其设置为禁用;然后在需要使用setEnabled:YES时启用它。
或者,如果您有多个 View Controller ,就会使用它。创建一个单独的 View Controller 并将您的 View 放入其中。以编程方式将此 View Controller 的 View 添加到每个 View Controller 。
PauseViewController *pauseVC = [self.storyboard instantiateViewControllerWithIdentifier:@"PauseID"];
[self.view addSubview:pauseVC.view];
关于iphone - iPhone开发中如何加载单独的UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11295518/