开发者

Add Data From One Table To Another Table

I have a tableview with genre: rock, rap, dance, country, pop, etc.

Lets say I have another tableView where I can make a custom list with a bunch of these genres.

Say in the mainView, I can add lists, like Dinner, Gym, Studying etc. Then within each of these lists (when you click its cell it will push to a subtableview for that list). I want to choose items from 开发者_如何学运维the separate genres to add to this subview. Examplple, Dinner list might include country and classical music, and gym list might have rock and rap etc.

I have everything set up so far except the code that lets me add genres to the custom sub groups. So I can make groups such as Dinner but I need to still make code that lets me fill this group with genres from the other tableView.

I think I need to have a modal view pop up when I click the add button. THis model view will have the genre table and when I click a cell, the modal view will dismiss and it will add whatever I clicked as a cell in the group.


Use the same genre array that backs the genre tables as the data source for the modal table. In the modal table didSelectRowWIthIndexPath, get the genre string from that array. Now you have lots of choices for how to get the genre item back to your detail table view controller. You could post a notification, you could use a KeyValue Observer, you could pass a reference to the detail VC to the modal and then the modal can set an exposed attribute on the detail VC, etc. Then the detail vc would add that genre value to whatever array is back it's data, and then you call reloadData on the detail VC table. Your modal VC would have to do something like [navigationController popViewController:animated] to dismiss itself.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜