I'm still coming up to speed on this iPhone development stuff. I've written a lot of code for Palm and WindowsCE devices so thought this would be easy, but I'm having a hard time getting my head around some these iPhone SDKs. It's getting there but slower than I expected.
So I want to display four columns of cards. My initial thought was to have a single view and draw everything in the view myself. But the more I learn about Views I'm wondering if it might be better to have each column as a subView of the main View instead. I could even go a step further and make each card be a subView inside each column View.
So my question is...is this a reasonable approach, or are their pitfalls to doing it this way?
Personally I think it's reasonable to have each part be its own view class. Makes for better modularity. Each class is specialized to do one thing. Good OO design. Of course it's more classes to manage but I think the benefits far outweigh the minor downsides.
If this is something like a solitaire game then making each card its own view will simplify things for you.
I wrote a sliding tile puzzle game as my first app. It has a 5 x 5 grid of tiles. I made each tile its own view and it worked out well. If you don't make each card its own view then you'll be duplicating some of the functionality of UIView for each card. Things l like hit testing and animations to move the cards are simple if they're individual views and complicated if you have to write them yourself.
The only issue I would think might come up is drawing performance. More than 20 or 30 views might take longer to draw or animate. However, you're probably only going to be manipulating one or a few views at a time so it shouldn't be a problem.
There's a class called CALayer that is reported to give faster drawing performance than a plain view but for your first app I'd recommend staying with UIView.
Thanks for the input. The cards are static once placed in a column so it perhaps doesn't make sense to make each card be a view. But I will take the approach of making each column a view.