我正在为我的应用添加一个额外的UIWindow.我的主窗口正确旋转,但我添加的这个附加窗口不会旋转.
根据当前设备方向旋转UIWindow的最佳方法是什么?
我正在开发一个应用程序,它需要显示覆盖范围以及其他所有内容.它通过创建一个新的UIWindow,并使用makeKeyAndVisble"接管"屏幕来实现这一点.完成后,它会将控制权返回给原始UIWindow.
这是一件坏事吗?感觉它正在控制应用程序的低水平,这通常很糟糕; 另一方面,它非常简单,所以也许完全可以接受.
意见/经验?
我一直在使用以下帖子作为如何显示UIAlertController与特定无关的from代码的指导UIViewController。现在,我要对该代码进行单元测试:
func showAlert(alert: UIAlertController, animated: Bool, completion: (()->Void)?)
{
let alertWindow = UIWindow(frame: UIScreen.mainScreen().bounds)
// Keep a strong refence to the window.
// We manually set this to nil when the alert is dismissed
self.alertWindow = alertWindow
alertWindow.rootViewController = UIViewController()
if let currentTopWindow = UIApplication.sharedApplication().windows.last {
alertWindow.windowLevel = currentTopWindow.windowLevel + 1
}
else {
// This case only happens during unit testing
Logger.trace(ICELogLevel.Error, category: .Utility, message: "The application doesn't have a window being displayed!") …Run Code Online (Sandbox Code Playgroud) 我知道有关于此问题的一些问题,但没有一个问题帮我解决了我的具体问题.我想在整个屏幕上方显示一个自定义模式,但我想保持Apple状态栏可见.对于模态,我使用一个UIView用于调光效果,另一个用于用户将与之交互的实际视图.然后将整个模态作为子视图添加到当前视图并转到前面.本质上,我试图复制UIAlertView的行为,除了自定义视图.这是我的一些代码:
var modalView:UIView = UIView(frame: self.view.window!.bounds)
modalView.backgroundColor = UIColor.blackColor().colorWithAlphaComponent(0.66)
modalView.addSubview(customView)
self.view.window!.addSubview(modalView)
modalView.window!.windowLevel = UIWindowLevelStatusBar + 1
self.bringSubviewToFront(modalView)
Run Code Online (Sandbox Code Playgroud)
以上customView是UIView用户与之交互的内容.
这很好用,但由于某种原因,即使状态栏的样式设置为LightContent,Apple状态栏上的文本也会消失.从代码中可以看出,我没有触摸状态栏.
我试图让状态栏上的文字像屏幕的其余部分一样暗淡,目前卡住了.有没有人对如何获得理想的行为有任何见解?
任何帮助将不胜感激!
ios ×3
uiwindow ×3
swift ×2
iphone ×1
keywindow ×1
objective-c ×1
overlay ×1
screen ×1
statusbar ×1
unit-testing ×1