[英]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.