Reputation: 518
I'm about to port my Five-in-a-row client to the iOS platform. Originally I've designed it in Java. There are 15*15 fields that need to be displayed. On the PC I represent fields with individual objects which only responsible for themselves (event handling, etc...). I'm not sure if it's a good idea to do the same on a mobile platform (I mean using 225 gesture recognizers doesn't sound too promising). There is another approach which merges all those fields into one big view which is responsible for the drawing and event handling by doing some math with screen coordinates. Personally I prefer the first approach, because it's more OO based. What do you think, which one should I prefer on iOS if performance is primary? Thanks in advance!
Upvotes: 2
Views: 320
Reputation: 39306
If performance is primary you can have a custom drawn view, use UIGestureRecognizer to get the CGPoint and only redraw the region (square) affected using UIView:
- (void)drawRect:(CGRect)rect
It's trivial to do that math.
But, depending on the complexity of the control and each cell, that code can be hard to maintain. Creating a layered control with subViews where each subview is responsible for how it draws, handles gestures etc... is much more maintainable and the code will end up being cleaner. Will it have more overhead? Yes. Will that be a problem? likely not. So, you need to try it and measure. It's common to create aggregate views with subviews and each of those subviews knowing how to draw and handle gestures - it's what cocoa touch is all about.
Upvotes: 4