Matt Egan
Matt Egan

Reputation: 809

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 can 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?

Upvotes: 1

Views: 892

Answers (2)

Jason Foreman
Jason Foreman

Reputation: 2146

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.

Upvotes: 1

Gary
Gary

Reputation: 5732

Write your own specialised UIView and do the drawing yourself.

Upvotes: 0

Related Questions