Esqarrouth / EZSwipeController

:point_up_2: UIPageViewController like Snapchat/Tinder/iOS Main Pages
MIT License
842 stars 71 forks source link

Question: Return correct view controllers? #47

Closed HackShitUp closed 7 years ago

HackShitUp commented 7 years ago

How do I return the correct view controllers? Here's my code that loops through the objects:

` // Loop through objects to determine which view controller to show for postObject in stackObjects {

        print("***STACKOBJECTS:***\(stackObjects)\n****")

        if postObject.value(forKey: "contentType") as! String == "tp" {
            // I) TEXT POST
            textPostObject.append(postObject)
            let textPostVC = self.storyboard?.instantiateViewController(withIdentifier: "textPostVC") as! TextPost
            // Append VC
            postControllers.append(textPostVC)

        } else if postObject.value(forKey: "contentType") as! String == "ph" {
            // II) PHOTO
            photoAssetObject.append(postObject)
            let photoVC = self.storyboard?.instantiateViewController(withIdentifier: "photoAssetVC") as! PhotoAsset
            // Append VC
            postControllers.append(photoVC)

        } else if postObject.value(forKey: "contentType") as! String == "pp" {
            // III) PROFILE PHOTO
            proPicObject.append(postObject)
            otherObject.append(postObject.value(forKey: "byUser") as! PFUser)
            otherName.append(postObject.value(forKey: "username") as! String)
            let proPicVC = self.storyboard?.instantiateViewController(withIdentifier: "profilePhotoVC") as! ProfilePhoto
            // Append VC
            postControllers.append(proPicVC)

        } else if postObject.value(forKey: "contentType") as! String == "sh" {
            // IV) SHARED POST
            sharedObject.append(postObject)
            let sharedPostVC = self.storyboard?.instantiateViewController(withIdentifier: "sharedPostVC") as! SharedPost
            // Append VC
            postControllers.append(sharedPostVC)

        } else if postObject.value(forKey: "contentType") as! String == "sp" {
            // V) SPACE POST
            spaceObject.append(postObject)
            otherObject.append(postObject.value(forKey: "toUser") as! PFUser)
            otherName.append(postObject.value(forKey: "toUsername") as! String)
            let spacePostVC = self.storyboard?.instantiateViewController(withIdentifier: "spacePostVC") as! SpacePost
            // Append VC
            postControllers.append(spacePostVC)

        } else if postObject.value(forKey: "contentType") as! String == "itm" {
            // VI) MOMENT
            itmObject.append(postObject)
            let itmVC = self.storyboard?.instantiateViewController(withIdentifier: "itmVC") as! InTheMoment
            // Append VC
            postControllers.append(itmVC)

        } else if postObject.value(forKey: "contentType") as! String == "vi" {
            // VII) VIDEO
            videoObject.append(postObject)
            let videoVC = self.storyboard?.instantiateViewController(withIdentifier: "videoVC") as! VideoAsset
            // Append VC
            postControllers.append(videoVC)

        }

    }`

Where postControllers, is an array that holds all the UIViewControllers. HOWEVER, even with the correct startingIndex, it doesn't load the correct UIViewController. How do I handle this correctly?

HackShitUp commented 7 years ago

Also, this is in the following function: func viewControllerData() -> [UIViewController] { }

The UITableViewControllers DO return, but not the correct ones. I took another look and found out that it only fetches 7 view controllers? I suspect it might be because of the setupViewController function in EZSwipeController, but I'm not sure yet. Also, the sizing constraints are very off - the UINavigationBar is customized and initialized by the parent view controller and returned accordingly to the 7 different types of UITableViewControllers, but every time I swipe down to the next view controller, the height of the navigation bar is increased on its own. I can share some screenshots if you'd like.

HackShitUp commented 7 years ago

bump because I need help