Open angelen10 opened 8 years ago
here is my code:
func safariViewController(controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool) {
let createButton: (CGRect, LiquidFloatingActionButtonAnimateStyle) -> LiquidFloatingActionButton = { (frame, style) in
let floatingActionButton = LiquidFloatingActionButton(frame: frame)
floatingActionButton.animateStyle = style
floatingActionButton.dataSource = self
floatingActionButton.delegate = self
return floatingActionButton
}
let cellFactory: (String) -> LiquidFloatingCell = { (iconName) in
return LiquidFloatingCell(icon: UIImage(named: iconName)!)
}
cells = [cellFactory("ic_cloud"), cellFactory("ic_system"), cellFactory("ic_place")]
let floatingFrame = CGRect(x: self.view.frame.width - 56 - 16, y: self.view.frame.height - 56 - 16 , width: 56, height: 56)
let bottomRightButton = createButton(floatingFrame, .Left)
bottomRightButton.color = themeColor
controller.view.addSubview(bottomRightButton)
print("SFSafariViewController加载完成")
}
I can't understand why it occurred. Do you have code about your layouts In other place?
In my ViewController:
class ArticleTableViewController: UITableViewController, SFSafariViewControllerDelegate, LiquidFloatingActionButtonDataSource, LiquidFloatingActionButtonDelegate
I write this code in a this ViewController, in the bar button item:
@IBAction func add(sender: UIBarButtonItem) {
if let url = NSURL(string: "http://iangelen.github.io/2016/0110/") {
let vc = SFSafariViewController(URL: url, entersReaderIfAvailable: false)
vc.delegate = self
vc.view.tintColor = themeColor
presentViewController(vc, animated: true, completion: nil)
}
}
while SFSafariViewController is didCompleteInitialLoad, I override this code:
func safariViewController(controller: SFSafariViewController, didCompleteInitialLoad didLoadSuccessfully: Bool) {
let createButton: (CGRect, LiquidFloatingActionButtonAnimateStyle) -> LiquidFloatingActionButton = { (frame, style) in
let floatingActionButton = LiquidFloatingActionButton(frame: frame)
floatingActionButton.animateStyle = style
floatingActionButton.dataSource = self
floatingActionButton.delegate = self
return floatingActionButton
}
let cellFactory: (String) -> LiquidFloatingCell = { (iconName) in
return LiquidFloatingCell(icon: UIImage(named: iconName)!)
}
cells = [cellFactory("ic_cloud"), cellFactory("ic_system"), cellFactory("ic_place")]
let floatingFrame = CGRect(x: self.view.frame.width - 56 - 16, y: self.view.frame.height - 56 - 16 , width: 56, height: 56)
let bottomRightButton = createButton(floatingFrame, .Left)
bottomRightButton.color = themeColor
controller.view.addSubview(bottomRightButton)
print("SFSafariViewController加载完成")
}
P.S.controller.view.addSubview(bottomRightButton) not self.view.addSubview(bottomRightButton), I add the floating action button to the SFSafariViewController
.
In iPad: