【发布时间】:2016-06-17 16:52:41
【问题描述】:
我有一个 UIButton 位于嵌套滚动视图中(水平分页滚动视图中的垂直分页滚动视图)。我的问题是当我点击它突出显示的按钮时,它不会触发我链接到的 segue。然后,我尝试将其链接到放置断点的 IBAction 函数,当我点击按钮时,我没有击中该断点,因此我的按钮也没有触发 IBActions。
我尝试关闭两个滚动视图的延迟内容触摸,但没有奏效。所做的只是在我点击按钮后立即突出显示它,而不是在突出显示之前稍微增加一点权重。无论哪种方式,当我点击它时,我的按钮都会突出显示,但我的所有插座(segues 或 IBActions)都没有触发,我认为这很奇怪。我在网上发现其他人有类似的问题,但他们的按钮甚至没有突出显示。我的亮点,所以我知道它从用户那里得到输入。
这是我实例化嵌套滚动视图的方式。主水平滚动视图是在我的故事板中创建的,然后在它的 ViewController viewDidLoad 方法中我这样做是为了嵌套垂直滚动视图。垂直滚动视图包含我的按钮。
let readingVC = storyboard!.instantiateViewControllerWithIdentifier("ReadingViewController") as! ReadingRingViewController
readingVC.read = reading.minutesRead
readingVC.goal = reading.minutesGoal
readingVC.selectedDate = selectedDate
readingVC.today = today
let readingView = readingVC.view
let scrollPage2 = UIScrollView(frame: CGRectMake(readingView.bounds.size.width,0,readingView.bounds.size.width, readingView.bounds.size.height))
scrollPage2.addSubview(readingView)
scrollPage2.contentSize = CGSize(width: readingView.bounds.size.width, height: readingView.bounds.size.height*2)
scrollPage2.pagingEnabled = true;
scrollPage2.alwaysBounceVertical = true
scrollPage2.userInteractionEnabled = true
let readingBottomView = storyboard!.instantiateViewControllerWithIdentifier("ReadingBottomViewController").view
let scrollPage2Bottom = UIScrollView(frame: CGRectMake(0,readingView.bounds.size.height,readingBottomView.bounds.size.width, readingBottomView.bounds.size.height*2))
scrollPage2Bottom.addSubview(readingBottomView)
scrollPage2Bottom.contentSize = CGSize(width: readingBottomView.bounds.size.width, height: readingBottomView.bounds.size.height)
scrollPage2.addSubview(scrollPage2Bottom)
scrollPage2.sendSubviewToBack(scrollPage2Bottom)
这是我的按钮所在的 viewController 的代码。我已将其链接到 IBAction 并将其链接到另一个 viewController 作为推送序列
@IBAction func start(sender: AnyObject) {
var x = 0
var y = 0
x = y + x
}
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
if segue.identifier == "StartReading" {
let destVC = segue.destinationViewController
}
}
【问题讨论】:
标签: ios iphone swift uiscrollview uibutton