0
我有一个UIAlertController,我正在尝试向它添加一个箭头并将sourceView更改为self.button,以便它不会出现在底部。Swift将箭头和sourceView添加到UIAlertController
这是我走到这一步:
let dropdown = UIAlertController(title: "Select Room", message: nil, preferredStyle: .ActionSheet)
let kitchen = UIAlertAction(title: "Kitchen", style: .Default) { (action) in
}
dropdown.addAction(kitchen)
let livingRoom = UIAlertAction(title: "Living Room", style: .Default) { (action) in
}
dropdown.addAction(livingRoom)
let bedroom = UIAlertAction(title: "Bedroom", style: .Default) { (action) in
}
dropdown.addAction(bedroom)
let bathroom = UIAlertAction(title: "Bathroom", style: .Default) { (action) in
}
dropdown.addAction(bathroom)
let cancel = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in
}
dropdown.addAction(cancel)
dropdown.modalPresentationStyle = .Popover
dropdown.popoverPresentationController?.sourceRect = self.dropdownButton.frame
dropdown.popoverPresentationController?.sourceView = self.dropdownButton
dropdown.popoverPresentationController?.permittedArrowDirections = .Up
self.presentViewController(dropdown, animated: true, completion: nil)
但箭头不会出现和UIAlertController仍然出现在底部。我究竟做错了什么?
您只能在iPad上看到箭头。在iPhone上,它总是全屏,没有箭头。 – rmaddy