简体   繁体   中英

How to load different data classes from Parse into uitableview with UISegementedControl -> Swift?

Fairly new to Parse backend and coding all together...

I am trying to implement a UISegmentedControl within a viewcontroller to load different Parse classes (User Products, User Services, User Favorites) into a uitableview . uitableview covers only half of the viewcontroller

I am wondering what is the best approach to properly implement this function? Please forgive me if my question seems too vague.

Thank you!

Your solution should have three components:

  1. Detect changes in your UISegmentedControl
  2. Load the appropriate data with a query
  3. Update the UITableView

    1. Detect Changes in your UISegmentedControl You can find an excellent tutorial here on implementing and detecting changes: http://www.mobisoftinfotech.com/blog/iphone/iphone-segmented-controluisegmentedcontrol-tutorial/

    2. Load the appropriate data with a query https://www.parse.com/docs/ios/guide#queries is where you can learn about how to format your queries for different Parse classes. Use a switch statement to decide which class to load.

    3. Update the TableView This one is the easiest. Use a global variable for your Swift class that stores the returned objects from the PFQuery . If you need to use different cell layouts for the classes, use a switch statement with your UISegmentedControl's index to determine how to load the data appropriately in your UITableView's cellForIndexPath: method.

Sorry I can't be more specific, but hopefully this helps!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM