nik*_*nik 22 iphone xcode cocoa objective-c uiview
我有一个我在AppDelegate类中添加的活动视图来点击栏:
[self.mainTabBar.view addSubview: spinner];
Run Code Online (Sandbox Code Playgroud)
当存在连接问题时,它在每个视图控制器中都可见并且正在旋转.某些视图控制器上有一些按钮,使得呈现一些模态视图控制器.该模态视图控制器与微调器重叠.如何使该微调器始终位于所有视图之上或至少位于该模态视图控制器之上?我试图在视图控制器中做出这样的事情,它呈现模态视图控制器:
[self presentModalViewController:selectionViewController animated:YES];
[self.view bringSubviewToFront:[self.tabBarController.view viewWithTag:15]];
Run Code Online (Sandbox Code Playgroud)
不行.
Fel*_*lix 62
将视图添加到主窗口.
UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
[mainWindow addSubview: spinner];
Run Code Online (Sandbox Code Playgroud)
Mac*_*wic 12
虽然phix23的答案是正确的,但这是一个更完整的例子:
//The view you want to present
UIViewController *viewControllerYouWantToPresentOnTop = [[UIViewController alloc] initWithNibName:nil bundle:nil];
//Create transparent host view for presenting the above view
UIWindow* mainWindow = [[UIApplication sharedApplication] keyWindow];
UIViewController *viewControllerForPresentation = [[UIViewController alloc] init];
[[viewControllerForPresentation view] setBackgroundColor:[UIColor clearColor]];
[[viewControllerForPresentation view] setOpaque:FALSE];
[mainWindow addSubview:[viewControllerForPresentation view]];
//Make your transparent view controller present your actual view controller
[viewControllerForPresentation presentViewController:viewControllerYouWantToPresentOnTop animated:TRUE];
Run Code Online (Sandbox Code Playgroud)
当你不再需要这些时,请记得自己清理干净.
此代码可以在您的应用程序中的任何位置使用,甚至是库:)
| 归档时间: |
|
| 查看次数: |
36162 次 |
| 最近记录: |