Şu anda bir UI ile Snapchat ScrollView'a benzer bir uygulamanız var. MainViewController üç çocuk ViewControllers çocuk ViewControllers olarak ilave edildiği bir UIScroll içerir:Offset UIScrollView bir çocuktan ViewController
override func viewDidLoad() {
super.viewDidLoad()
scrollView.contentSize = CGSizeMake((self.view.bounds.width*3 + 4), self.view.bounds.height)
self.view.addSubview(scrollView)
let view1 = UIView(frame: CGRectMake(0, 0, self.view.bounds.width, self.view.bounds.height))
scrollView.addSubview(view1)
let aVC = self.storyboard?.instantiateViewControllerWithIdentifier("One")
view1.addSubview(aVC!.view)
self.addChildViewController(aVC!)
let view2 = UIView(frame: CGRectMake((self.view.bounds.width), 0, self.view.bounds.width, self.view.bounds.height))
scrollView.addSubview(view2)
let bVC = self.storyboard?.instantiateViewControllerWithIdentifier("Two")
view2.addSubview(bVC!.view)
self.addChildViewController(bVC!)
let view3 = UIView(frame: CGRectMake(2*view.bounds.width), 0, self.view.bounds.width, self.view.bounds.height))
scrollView.addSubview(view3)
let cVC = self.storyboard?.instantiateViewControllerWithIdentifier("LocationViewController")
view3.addSubview(cVC!.view)
self.addChildViewController(cVC!)
scrollView.contentOffset = CGPointMake(self.view.frame.width, 0
}
Ben düğmeleri iki Scrollview için sağ veya sol Görünüm Kontrolörler telafi edecek orta ViewController, eklemeye çalışırken. MainViewController'da setContentOffset() öğesini kullanabileceğimi biliyorum, ancak bunu çocuk görüntü denetleyicilerinde arayamıyorum. Hem self.presentingViewController hem de self.parentViewController her ikisi de sıfır.
Çocuk ViewController içinde, UIScrollView için setContentOffset() yöntemini çağırmanın en iyi yolu nedir?