简体   繁体   English

ios-两个表视图之间的Segue

[英]ios - Segue between two table views sqlite

I have the following tables 我有下表

Bike Brands (Parent): 自行车品牌(家长):

      id | brand
---------------------
       1  |  Trek
       2  |  Salsa

Bike Models (Child) 自行车模型(儿童)

      id  |    model        | brandid
------------------------------------------
       1  |  Superfly FS    | 1
       2  |  Vaya 3         | 2
       3  |  Superfly 9 SL  | 1
       4  |  Vaya 7         | 2

I have two UITableViewController. 我有两个UITableViewController。 I want to pass from one tableview to another and to show only bikes from the chosen brand. 我想从一个表视图传递到另一个表视图,只显示所选品牌的自行车。

To pass data from one tableview to another need to use prepareForSegue? 要将数据从一个表视图传递到另一个表视图,需要使用prepareForSegue吗?

I tried different queries inner join to show bikes from chosen brand but I cant find one that is working. 我尝试了不同的内部联接查询,以显示所选品牌的自行车,但找不到有效的自行车。

""ex: What I want is when choose brand for EX Trek to show all models for this brand in another tableview “” ex:我想要的是为EX Trek选择品牌时,在另一个表格视图中显示该品牌的所有型号

let's you have one tableview on screen with brand detail like brand name and id. 让我们在屏幕上显示一张带有品牌详细信息(如品牌名称和ID)的表格视图。

when user click on any brand then pass that brand's id in next view controller. 当用户单击任何品牌时,然后在下一个视图控制器中传递该品牌的ID。

now in second view controller in viewDidAppear call method to retrive data who has the same brand id that you selected in previous controller. 现在在viewDidAppear调用方法的第二个视图控制器中,以检索与您在上一个控制器中选择的品牌ID相同的数据。

here is the query 这是查询

Query : select * from Bike Models where brandid=(selected brand id in previous controller) 查询 :从自行车模型中选择*,其中brandid =(在先前控制器中选择的品牌ID)

this will return array contains all bikes data who match above query. 这将返回包含与上述查询匹配的所有自行车数据的数组。

and then just reload you table view. 然后只需重新加载表格视图即可。

Hope this will help you. 希望这会帮助你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在iOS的两个表格视图之间自定义动画(segue)? - how to customise animation(segue) between 2 table views in iOS? 在表视图之间传输数据而没有安全性? - transfer data between table views without segue? 如何通过根表视图控制器中的swift在两个表视图之间建立Segue连接? - How to establish Segue connection between two table views via swift in the root table view controller? 如何在涉及选项卡栏,表格视图和导航控制器的两个视图之间进行筛选? - How to segue between two views involving a tab bar, table view and navigation controller? 带有NavigationController的情节提要中两个视图之间的Segue / Transition - Segue/Transition between two views in a storyboard w/o a NavigationController 在 UITabBar 视图之间“滑动”segue - "Slide" segue between UITabBar views 两个连续的警报视图,然后进行Segue - Two Consecutive Alert Views and then Segue 在iOS 7中在两个简单的View Controller之间进行筛选的正确方法 - Proper way to segue between two simple View Controllers in iOS 7 ios:横向模式下两个viewcontrollers之间的自定义Segue - ios: Custom Segue between two viewcontrollers in landscape mode 两个TabbarControllers之间的Segue - Segue between two tabbarcontrollers
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM