开发者

UISwitch propagate state

I'm still rather new to iPhone development and I tried something I didn't it was possible. I have a UIView for my TableView Section Header with a s开发者_StackOverflow社区witch on it, and I also have a UITableCellView with another Switch on it. It all looks fine, but now I want to propagate the UISwitch state from the section header to all the UISwitches on the section rows. Can anyone enlighten me how can I accomplish this?

Thank you.


Create a mutable array and whenever you create a table cell with a switch save a reference to the switch as a new element in the array. Then when the switch in your section header is changed, loop over the array and send a message to each switch, telling it to update its state.

UPDATE: for multiple sections, do the following

To keep track of which switch belongs to which header, set the tag property on the switches in the headers:

[myHeaderSwitch setTag:sectionHeader];

Then have an array of mutable arrays, one for each section as described above and use this to update the switches in the correct section

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜