Skip to content

Commit

Permalink
Fix so alert view shows up in center when using iOS 9 split-screen mu…
Browse files Browse the repository at this point in the history
…ltitasking on an iPads
  • Loading branch information
kee23 committed Sep 16, 2015
1 parent 4352ae4 commit ea49ddb
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 22 deletions.
15 changes: 4 additions & 11 deletions Example/SCLAlertViewExample/SCLAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,9 @@ public class SCLAlertView: UIViewController {

override public func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
var sz = UIScreen.mainScreen().bounds.size
let sver = UIDevice.currentDevice().systemVersion as NSString
let ver = sver.floatValue
if ver < 8.0 {
// iOS versions before 7.0 did not switch the width and height on device roration
if UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication().statusBarOrientation) {
let ssz = sz
sz = CGSize(width:ssz.height, height:ssz.width)
}
}
let rv = UIApplication.sharedApplication().keyWindow! as UIWindow
let sz = rv.frame.size

// Set background frame
view.frame.size = sz

Expand Down Expand Up @@ -766,4 +759,4 @@ class SCLAlertViewStyleKit : NSObject {
UIGraphicsEndImageContext()
return Cache.imageOfEdit!
}
}
}
15 changes: 4 additions & 11 deletions SCLAlertView/SCLAlertView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -160,16 +160,9 @@ public class SCLAlertView: UIViewController {

override public func viewWillLayoutSubviews() {
super.viewWillLayoutSubviews()
var sz = UIScreen.mainScreen().bounds.size
let sver = UIDevice.currentDevice().systemVersion as NSString
let ver = sver.floatValue
if ver < 8.0 {
// iOS versions before 7.0 did not switch the width and height on device roration
if UIInterfaceOrientationIsLandscape(UIApplication.sharedApplication().statusBarOrientation) {
let ssz = sz
sz = CGSize(width:ssz.height, height:ssz.width)
}
}
let rv = UIApplication.sharedApplication().keyWindow! as UIWindow
let sz = rv.frame.size

// Set background frame
view.frame.size = sz

Expand Down Expand Up @@ -766,4 +759,4 @@ class SCLAlertViewStyleKit : NSObject {
UIGraphicsEndImageContext()
return Cache.imageOfEdit!
}
}
}

0 comments on commit ea49ddb

Please sign in to comment.