OfTheWolf / TwitterProfile

Nested scrolling with pager just like in Twitter and Instagram profile.
MIT License
266 stars 45 forks source link

Is there a function to reload for sending data from main controller to header and bottom controller after calling API? #5

Closed codobuxsocial closed 4 years ago

codobuxsocial commented 4 years ago

Thanks alot first of all, this library has been really helpful and should have much more attention since it pretty awesome.

  1. My question now is I am calling API in main controller where we have given TPDataSource, after fetching data from API i want to forward it to header and bottom controllers. Can you tell me how we can achieve that?

  2. Also is there a way to blur the image when content is scrolled up top and show user name over it?

OfTheWolf commented 4 years ago

@codobuxsocial Thanks for nice words.

  1. You must already have a reference to headerVC and bottomVCs in main view controller. So you can pass data thorough that reference.

%path to example%/ViewController.swift

  func headerViewController() -> UIViewController {
        headerVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "HeaderViewController") as? HeaderViewController
        return headerVC!
    }

    func bottomViewController() -> UIViewController & PagerAwareProtocol {
       pagerVC = UIStoryboard.init(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "XLPagerTabStripExampleViewController") as! XLPagerTabStripExampleViewController
        return pagerVC
    }

 headerVC.passData(...)  // you can call anywhere in the code
 pagerVC.passData(...)  // you can call anywhere in the code
  1. See below TPProgressDelegate method. You can use progress to implement blur effect on scroll.

    //MARK: TPProgressDelegate
    func tp_scrollView(_ scrollView: UIScrollView, didUpdate progress: CGFloat) {
        headerVC?.adjustBannerView(with: progress, headerHeight: headerHeight())
    } 
codobuxsocial commented 4 years ago

Thanks for the quick response, will play around with it!