简体   繁体   中英

VoiceOver Page Announcement is Incorrect

With VoiceOver turned on, the current page is announced when the user scrolls by swiping with three fingers, eg: "Page 1 of 3". However, these announcements are not always correct.

The following code creates a scroll view and populates it with three labels (with different background colours to differentiate them):

let scrollView = UIScrollView()
scrollView.frame = view.bounds
view.addSubview(scrollView)

let colours: [UIColor] = [.red, .blue, .green]
var lastView: UIView?

for colour in colours {
    let label = UILabel()
    label.frame.size = scrollView.frame.size
    label.backgroundColor = colour
    label.textColor = .white
    label.text = "\(colours.firstIndex(of: colour)!)"
    label.textAlignment = .center

    scrollView.addSubview(label)

    label.frame.origin.y = lastView?.frame.maxY ?? 0

    lastView = label
}

scrollView.contentSize.height = lastView!.frame.maxY        

When I scroll (as explained above), the following announcements are made:

  • Page 1 of 4
  • Page 2 of 4
  • Page 4 of 4
  • Page 4 of 4

Is there something I'm doing wrong or is this a bug in iOS? If it is the latter, is there any workaround I can apply to ensure the correct page numbers are announced?

As you mentioned in your comment, I misunderstood your problem.

Is there something I'm doing wrong or is this a bug in iOS?

You're doing nothing wrong : the system calculates the total amount of pages necessary to scroll the content with a three-finger vertical swipe and it doesn't have to match your label's number.

Take a look at the displayed colored label provided by your code hereunder: 在此处输入图片说明 Each swipe doesn't display a label on its entire height and width, that's why you have more pages than label amount: that's definitely not a bug, that's the way it works .

... is there any workaround I can apply to ensure the correct page numbers are announced?

However, if that's what you're willing to reach, I suggest to take a look at the custom scrolling that might help (I never used it but that's the only line of inquiry I see for your goal) .

So, unfortunately no workaround for the problem you mentioned because it often happens even for the native iOS apps.

See the most right-hand page on your iPhone with the widgets and listen the page numbers that are announced: the first announcement is always wrong for me (5 pages while there are only 3) .

The first announcement/reading is sometimes wrong but after some three-finger vertical swipes, the system corrects its initial error as I pointed out with my illustration.

That's not a perfect situation for the user but, for now, you can't do anything better unless lighting a candle for a very soon fix of this problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM