开发者

Better to use UIScrollView or UITableView for horizontal buttons?

开发者 https://www.devze.com 2023-03-30 10:59 出处:网络
I have a page enabled scrollview on an iPad. On the first page, I have a child scrollview that scrolls horizontally through image buttons. The buttons scroll the outer scroll view to the correct page.

I have a page enabled scrollview on an iPad. On the first page, I have a child scrollview that scrolls horizontally through image buttons. The buttons scroll the outer scroll view to the correct page. Its basically like a table of contents that jumps to the correct page.

My end goal is to be able to categorize the buttons seen in the child scroll view. So there would be a segmented control that changes what buttons you can see. So maybe one category would be ALL, and another category would be A-M, and another would be N-Z for example.

My question is, should I use a uiscrollview or a uitableview?

Right now I use a scrollview and it is really easy to get the开发者_StackOverflow社区 buttons in. I could implement the different categories kind of gimmicky by having all of the buttons in the scrollview and then just showing or hiding the buttons accordingly. I feel that it'd be bad memory usage though.

For a uiscrollview i was looking at using EasyTableView, butI'm not 100% sure if this is compatible with what i want to do or if it'd even be better.

Any ideas for what the best way to implement this is? Specifically, I'm not sure of the best way to change the buttons when I change categories.

Thanks!


Use a tableview when you are dealing with data that is best expressed as sections and rows.

I think for your situation I'd have a UIView subclass that can display the images you need for a given category. Stick that on the outer scrollview as needed. You can keep memory low by only keeping the currently visible view and the ones on either side on the scrollview. When you scroll to a new location you can recreate the view needed for that page, and the ones surrounding it. Then you release the ones that are far away and let the system reclaim their memory if needed.

0

精彩评论

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