开发者

Memory/performance trading question? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 11 years ago.

What is the best?

I want to handle about 400 buttons (the buttons have 4 state). What is the best? To store/display 4 different OPAQUE image for each button, or assamble the states from 2 ALPHA MASKED png?

I know that the question is a bit foggy. More OPAQUE 开发者_运维百科image, or less but ALPHA MASKED?

If there's any experience, please share.


As I mentioned before, I really don't think this would be a good idea (from an UX perspective). However, if you do want to do this, you should 'hack' a little bit to increase the performance.

Instead of using 400 (or even 400 * 4 = 1600) UIViews (or UIButtons, which would basically be the same in this case), you should stick to one subclassed UIView and override the drawRect: method for faster and cached drawing.

You can override the touchesBegan ..., touchesMoved ..., etc. events to track touch events. When a user presses one 'button' (actually, it presses in your single view, but you can measure in what button it'ld be), you update a single int-variable and call setNeedsDisplay to redraw the 'buttons'.


That depends on where exactly you'll be using them. If we are talking about static positions - use alpha masked. On tables(and any scroll enabled views) you need to check performance first.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜