用于数独网格的 UIKit 控件?
我最近用 C 语言完成了一个算法数独求解器,其中采用三种不同的方法来解决这个难题。这是我为 Project Euler 解决方案编写的一段代码。相当有趣,我可能会补充...
任何人,所以我真的很感兴趣将这个小解算器放入 iPhone 应用程序中。我真的不知道要采取什么方法才能在屏幕上显示网格。我能想象的最糟糕的方式是为 81 个单独的 UITextFields 提供 81 个单独的出口...在可可应用程序中,我只需将它们嵌入到 NSMatrix 中即可,但 iPhone 上没有 NSMatrix 的替代品。
我现在正在考虑生成一个 HTML 文件并将其显示在 UIWebView 中,但即使这似乎也不是解决此问题的最佳方法。你会推荐什么?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我会从一些非常简单的事情开始:一个 UIView 子类,它有一个 81 元素数组,并且知道如何通过在其 drawRect: 调用中绘制或在layoutSubviews 中添加子视图或子层来将其渲染为 9x9 网格。在数组索引和网格矩形之间映射应该很容易。该视图还可以绘制您想要的任何背景网格/线条。
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.
编写您自己的专用 UIView 并自己绘制。
Write your own specialised UIView and do the drawing yourself.