Hey all, My focus is normally on IB, because it's still so clunky with VoiceOver. But now I have a situation where I'm not sure IB is the best way to go, and I'd like your input as to how I should proceed.
I'm making a game based on a board. Every square on the board will be a UIButton so users can tap it. I know the size of the board (2x6) but in similar projects I may not--that is, the board size may be set by a user preference. In either case, I don't look forward to making a bunch of individual IBOutlets, and wonder if there might be a better way. Plus, with an arbitrarily-sized board, I couldn't make and wire up the outlets.
In such a situation, how would I do this? I'll need each button to respond to a single tap, tap and hold, and double tap. Those gestures will cause different moves which will update the model and then be reflected in the UI, as normal, but how would I make the bindings without outlets? I'm using stacks, so would a manual creation of a UIButton instance which is added to the stack be the best way? If I do that, I can lay out the buttons, but how do I then bind them? Though I haven't gotten this far, I imagine all the buttons using the same few functions and for the functions to take the buttons' positions into account, rather than having a bunch of functions (three per button) that all call master functions. Either way, though, binding things is where I'm unsure. Is there an easier step than all the manual code that I'm missing? Is manual creation/binding not as bad as I'm imagining? This is Xcode 8, Swift 3, in an iOS app project created fresh in 8. Thank in advance!
--
Have a great day, Alex Hall
|