这是我的简单按钮操作,用于显示 XIB 文件,该文件实际上是 Objective-C 中的条形码扫描仪。
- (IBAction)startCamera:(id)sender {
BarcodeVC * controller = [[BarcodeVC alloc] initWithNibName:@"BarcodeVC" bundle:[NSBundle mainBundle]];
//[self presentViewController:controller animated:YES completion:nil];
UIWindow * currentwindow = [[UIApplication sharedApplication] keyWindow];
[currentwindow.rootViewController presentViewController:controller animated:YES completion:nil];
}
Run Code Online (Sandbox Code Playgroud)
但不幸的是,一个警告来了:
keyWindow已弃用:首先在 iOS 13.0 中弃用
我知道iOS 13支持多场景,但是Objective-C有没有办法解决这个问题?我见过 Swift 版本,但使用 Objective-C 却没有成功。