英語系統の情報も見つからなかったので加えて併記しておきます。
Scroll down for English users!
iOS 11 から Large Title があるが,UITableViewController
や UICollectionViewController
を一番上までスクロールしたいケースがある(例えば,選択済みの TabBar Item をもう一度タップした場合など)。
答え: Large Title 状態を復元したい場合,コンテンツより 52pt 上の領域にスクロールすると message を送れば良い。
以下は Xamarin での例
var offset = scrollView.ContentOffset; var inset = UIDevice.CurrentDevice.CheckSystemVersion(11, 0) ? scrollView.AdjustedContentInset : scrollView.ContentInset; if (offset.Y <= -inset.Top) return; offset.Y = -inset.Top; scrollView.SetContentOffset(offset, true);
以上。
In iOS 11, program scrolls to top in UIScrollView with Large Title Navigation Bar.
iOS 11 UI controls has Navigation Bar with Large Title. In the case, scroll to top on UITableViewController
or UICollectionViewController.
(e.g. when tap selected tab bar)
Answer: Send message to UIScrollView, that scroll to "the top of content area - 52pt."
The sample is the following program in Xamarin.iOS (C#):
var offset = scrollView.ContentOffset; var inset = UIDevice.CurrentDevice.CheckSystemVersion(11, 0) ? scrollView.AdjustedContentInset : scrollView.ContentInset; if (offset.Y <= -inset.Top) return; offset.Y = -inset.Top; scrollView.SetContentOffset(offset, true);