用于数独网格的 UIKit 控件?

发布于 2024-09-11 08:37:23 字数 345 浏览 7 评论 0原文

我最近用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

眼角的笑意。 2024-09-18 08:37:23

我会从一些非常简单的事情开始:一个 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.

不再让梦枯萎 2024-09-18 08:37:23

编写您自己的专用 UI​​View 并自己绘制。

Write your own specialised UIView and do the drawing yourself.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文