0

I am new to iOS, although I have been with the basics and now I am trying developing a crossword app. Any suggestion where to start.

What problem I am facing the most, is to develop the 15 X 15 checkered board. I thought of two possible solutions -

  1. To put 15 TextFields in each 15 rows, and according to the requirement I am going to disable the textfields and add black background color. But also there are two question, since the a crossword box has a number to the upper left corner, how can I put it? And the second is is it going to affect my performance since there are so many text fields.

  2. Another possible solution I have thought of is coding a the board with CGRect and CGContextAddRect to the specified positions. But I am having problem on how to interact with the CGRect, that is when clicked it will bring up the key board and user can type the letter.

Please help, I don't know to where to start from. Other solutions are also acceptable.

Debopam Mitra
  • 1,842
  • 4
  • 27
  • 51

3 Answers3

4

I would suggest a UICollectionView. This is similar to a UITableView but with multiple rows and columns. Each UICollectionViewCell should consist of a UITextField.

For the numbers, you could either do that statically, i. e. you do it in your story board (place a UITextField for each number, the remaining space will be the UICollectionView.

Or (what I would prefer, but requires more logic) you make a 16x16 board and the 0th section and every 0th row in a section will be used for the numbers, the rest is for the actual crossword.

Marc
  • 6,051
  • 5
  • 26
  • 56
  • If you have a custom view you can just draw the small number int a corner of the view – Abizern Oct 17 '13 at 07:38
  • Did you already build a grid like this inside a `UICollectionView`? If yes, how should the zooming work because I try to solve this problem here http://stackoverflow.com/q/22358563/1141395? because `UICollectionView` is not designed to work horizontally and vertically at the same time. – Alex Cio Mar 13 '14 at 10:41
1

A best way is to use UICollectionView is you are targeting for iOS6+ or AQGridView if targeting older versions. Every cell is eventually a UIVIew.

Having custom textfield might make things complicated. Use UIKeyboard and set delegate as your collection view. In didselectrowAtIndex show your keyboard. Any keyboard delegate will return you character which you can set to Label at that box

There are few advantages for this over textfield approach

1) You can easily customize UIView/UILabel as compared to UITextField.
2) Labels can have custom fonts and attributed strings .
3) It's difficult to hide cursor in UITextField. which shows an editing mode.

Cons: Need Keyboard settings for Label. (However you can overcome with alternative controls like pickerview)

Also, make sure that you don't store any values in your views. Always refresh view from your data-structure (A 2-d array of characters).

Kunal Balani
  • 4,739
  • 4
  • 36
  • 73
0

Just a grid of views with labels in them should work. You might think its a good idea to be able to enter each character in place but it isn't. The user will have t tap Ana square type, type on another square, type...

So if you use labels you can have a different UI that let's the user enter a string in now go and then you can put the characters int the correct labels.

Abizern
  • 146,289
  • 39
  • 203
  • 257