UIKit controls for a sudoku grid?
I've recently completed an algorithmic sudoku solver in C, one in which three different approaches are taken to solve the puzzle. It was a piece of code I wrote for a Project Euler solution. Quite a bit of fun, I might add...
Anywho, so I'm really interested in getting this little solver into an iPhone app. I really am at a loss for what approach I am to take into getting the grid represented on screen. The worst way I c开发者_如何学Goan imagine would be having 81 individual outlets for 81 individual UITextFields... In a cocoa app I would simply embed them into a NSMatrix and be on my way, but there isn't a replacement for NSMatrix on the iPhone.
I'm thinking now about generating an HTML file and displaying that in a UIWebView, but even that doesn't seem the best way to go about this. What would you recommend?
I'd start with something quite simple: a UIView subclass that has an 81 element array and knows how to render this into a 9x9 grid either by drawing in its drawRect: call or by adding subviews or sublayers in layoutSubviews. It should be pretty easy to map between array indexes and grid rects. This view can also draw whatever background grid/lines you want.
Write your own specialised UIView and do the drawing yourself.
精彩评论