I have two questions with a long action sheet including 20 options (larger than the screen height):
Question 1. How to disable vertical bounces while scrolling?
Question 2. How to show the line separators while scrolling to the bottom?
Missing line separators of Question 2:
I am using Xcode 6.4 and iOS 8.4 simulator. The two issues also exist with my iPad running the same code on iOS 9.0.2.
I have created an action sheet using UIAlertControllerStyle.ActionSheet
. I have added 20 options in the action sheet using addAction
.
My ViewController.swift is as below:
override func viewDidLoad() {
super.viewDidLoad()
let button = UIButton(frame: CGRectMake(50, 60, 200, 20))
button.setTitle("Press", forState: UIControlState.Normal)
button.setTitleColor(UIColor.blueColor(), forState: UIControlState.Normal)
button.addTarget(self, action: "btnPressed:", forControlEvents: UIControlEvents.TouchUpInside)
view.addSubview(button)
}
func btnPressed(sender: UIButton) {
let controller = UIAlertController(title: nil, message: nil, preferredStyle: UIAlertControllerStyle.ActionSheet)
for item in 1...20 {
controller.addAction(UIAlertAction(title: "Option \(item)", style: UIAlertActionStyle.Default, handler: { action in
}))
}
controller.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Cancel, handler: nil))
presentViewController(controller, animated: true, completion: nil)
}
For Question 1:
Is there any bounces property that can be set like in UITableView: tableView.bounces = false
to prevent long action sheets from vertical bounces while scrolling?
For Question 2:
This is different from "UIActionSheet is not showing separator on the last item on iOS 7 GM", which uses the deprecated UIActionSheet
in stead of UIAlertController
with UIAlertControllerStyle.ActionSheet
. Adding the "Cancel" option to the action sheet does not seem to be a solution.
If I add a title or message to the action sheet or remove the "Cancel" option from it, bottom line separators are still missing.
Is it possible to show these missing lines?