一个页面(ViewController)随便写控件,button ,View之类的 addsubview 添加到 self.VIEW 上。 结果控件完全不显示。
但是通过 [[UIApplication sharedApplication].keyWindow addSubview:btn] 却可以显示出来。。
控件 frame 正常 且打印 subviews 可以看到 控件 添加到 view 上了。
搞不懂到底什么原因。
使用 bringSubviewToFront 依然不显示。所以感觉也不是顺序的原因。
求助大神帮忙。
但是通过 [[UIApplication sharedApplication].keyWindow addSubview:btn] 却可以显示出来。。
控件 frame 正常 且打印 subviews 可以看到 控件 添加到 view 上了。
搞不懂到底什么原因。
使用 bringSubviewToFront 依然不显示。所以感觉也不是顺序的原因。
求助大神帮忙。
解决方案 »
- NSSavePanel设置以文件后缀过滤setAllowedFileTypes遇上的问题
- iphone上的蓝牙编程可以实现虚拟串口服务与wince上的蓝牙通信吗?
- 特效实现
- UIView的一个bug?
- 请问有看过这几个IOS视频的吗?哪个相对要好些,传智、互联、千峰。本人基础薄弱。
- iOS 图片列表缩放 uiscrollview 放大 缩小
- iOS native和H5是怎么相互交互的?
- ios webview 使用loadHTMLString方法加载html数据 怎么异步加载出图片?
- IOS,集成webRTC 与支付宝openssl中的冲突问题
- 请问能修改软键盘上特定按钮的背景色?
- iOS textView.attributedText 插入NSTextAttachment显示图片后内存泄漏
- 如何 使 block 中代码先运行后在执行下面的代码
bringSubviewToFront:
把指定的子视图移动到顶层
- (void)bringSubviewToFront:(UIView *)view
参数
view
需要移到顶层的视图
@try {
[super viewDidLoad];
if( ([[[UIDevice currentDevice] systemVersion] doubleValue]>=7.0)){
self.edgesForExtendedLayout = UIRectEdgeNone;
self.extendedLayoutIncludesOpaqueBars = NO;
self.modalPresentationCapturesStatusBarAppearance = NO;
}
UIView *view = [[UIView alloc]initWithFrame:CGRectMake(0, 100, 200, 100)];
view.backgroundColor = [UIColor purpleColor];
[self.view addSubview:view];
//[[UIApplication sharedApplication].keyWindow addSubview:view];
NavigationRoot *navRoot = (id)self.navigationController;
[navRoot drawNavBar:self.navigationItem title:@"选择客户"];
rightButton = [UIButton buttonWithType:UIButtonTypeSystem];
rightButton.frame = CGRectMake(0, 0, 40, 30);
[rightButton setTitle:@"下载" forState:UIControlStateNormal];
[rightButton addTarget:self action:@selector(pressRightBtn:) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *rightButtonItem = [[UIBarButtonItem alloc] initWithCustomView:rightButton];
self.navigationItem.rightBarButtonItem = rightButtonItem;
[self.tableview registerNib:[UINib nibWithNibName:@"CustomerTableViewCell2" bundle:nil] forCellReuseIdentifier:@"CustomerTableViewCell2"];
isPlanned = 0;
[[Common Init] clipTableViewMoreLines:_tableview];
[self getAllTableViewDataSources];
[self showLocationMessage];
[self initBottomSearchView]; [self initSearchView]; }
@catch (NSException *exception) {
[CommonErrorHandler Handler:exception];
}
}如上 视图生命周期方法中只实现了 ViewDidLoad 我将其他代码全部注释掉。只留下测试 View 依然不显示。但是加在 keywindow 可以显示。
没用的。早试过了。我怀疑是 xib 的问题 但是又调不出来。因为我把所有代码注释掉,只留下测试 View 依然不显示。
[self.window makeKeyAndVisible];