UIView喜欢花哨的app个人资料

时间:2015-08-20 10:25:32

标签: ios xcode uitableview uiscrollview uicollectionview

我正在尝试使用应用Fancy的配置文件视图的外观开发视图。

https://appsto.re/es/VA0ry.i

真正困扰我的是分页水平滚动和垂直滚动与分页,以便像选择器和滚动一样粘贴菜单。

有人可以指导我吗?

感谢。

根据你的建议,我来创建这个观点:

    import UIKit

class DetalleTiendaScrollViewController: UIViewController, UIScrollViewDelegate {

    @IBOutlet weak var scrollView: UIScrollView!
    var pagesContainer = DAPagesContainer()

    var sugerencias:MyCompraCollectionViewController!
    var vistaOfertas:OfertasCollectionViewController!



    var ofertasConnection:OfertasConnection = OfertasConnection()
    var sugerenciasConnection = SugerenciasConnection()


    override func viewWillAppear(animated: Bool) {
        super.viewWillAppear(animated)
        self.pagesContainer.setSelectedIndex(pagesContainer.selectedIndex, animated: false)
    }
    override func viewWillDisappear(animated: Bool) {
        super.viewWillDisappear(true)
        ofertasConnection.activa = false
    }

    override func viewDidLoad() {
        super.viewDidLoad()

        // Do any additional setup after loading the view.
        scrollView.delegate = self
        pagesContainer.willMoveToParentViewController(self)

        //        pagesContainer.setSelectedIndex(1, animated: false)
        var altoNavigation = UIApplication.sharedApplication().statusBarFrame.size.height
        if let navHEit = navigationController?.navigationBar.frame.size.height {
            altoNavigation = altoNavigation + navHEit
        }
        var altoTab:CGFloat = 0
        if let b = self.tabBarController?.tabBar.frame.size.height {
            altoTab = b
        }
        pagesContainer.view.frame = CGRectMake(0, 370, self.scrollView.frame.size.width, self.scrollView.frame.size.height+500)
        pagesContainer.view.autoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight

        pagesContainer.view.setTranslatesAutoresizingMaskIntoConstraints(false)
        self.scrollView.addSubview(pagesContainer.view)



        pagesContainer.didMoveToParentViewController(self)

        self.sugerenciasConnection.getSugerencias()
        self.ofertasConnection.getOfertasOnline(0)



        vistaOfertas = self.storyboard?.instantiateViewControllerWithIdentifier("OfertasCollectionViewController") as! OfertasCollectionViewController
        vistaOfertas.ofertasConnection = self.ofertasConnection
        vistaOfertas.indice = 1

        vistaOfertas.collectionView!.gestureRecognizers = self.scrollView.gestureRecognizers


        sugerencias = self.storyboard?.instantiateViewControllerWithIdentifier("MyCompraCollectionViewController") as! MyCompraCollectionViewController
        sugerencias.sugerenciasConnection = self.sugerenciasConnection
        sugerencias.indice = 2


        vistaOfertas.didMoveToParentViewController(self)
        sugerencias.didMoveToParentViewController(self)


        vistaOfertas.title = "Ofertas online"
        sugerencias.title = "Sugerencias"

        pagesContainer.viewControllers = [sugerencias,vistaOfertas]
        println(scrollView.contentSize)
        self.scrollView.delaysContentTouches = false
        self.scrollView.canCancelContentTouches = false
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }

    @IBAction func scroll(sender: AnyObject) {
        self.scrollView.setContentOffset(CGPointMake(0, 200), animated: true)
    }

    func scrollViewDidScroll(scrollView: UIScrollView) {

        println(self.scrollView.contentOffset)
        if scrollView.contentOffset.y >= 305 {
            self.scrollView.contentOffset.y = 305
        }
    }
}

但是当我vistaOfertas滚动时,滚动会在vistaOfertas和ScrollView中重现。是否有任何方法可以阻止滚动,而scrollView的contentOffset没有305?

由于

1 个答案:

答案 0 :(得分:0)

这是一个非常广泛的问题。我将首先实现水平滚动和屏幕顶部。从那时起,您可以考虑添加垂直滚动以包装所有现有内容,或者只需添加平移手势来处理用户开始滚动到顶部的情况(您需要制作手册)当用户向上滚动/向上拖动时,如果您想使其外观和行为与您所指的应用相似,则会更改到屏幕顶部。

此时,您可能会开始遇到不同手势/滚动视图之间的通信问题。一个人会打断另一个人,或者可能会偷走"偷窃"印刷机。处理它有多种方法,具体取决于您将面临的确切问题。我强烈建议您观看Session 235 (Advanced Scrollviews and Touch Handling Techniques) from WWDC 2014 它通过各种手势和滚动视图完全协商这些问题。

祝你好运!