Skip to main content

iOS Tutorial Resources and UITableViewController

I began my app with a super simple view for the user's history. I used 1 huge label and just threw text at it. It didn't look pretty, but it got the data on to the screen. As I have been working with the app on a daily basis, it has become obvious to me that this is the biggest issue that needs to get addressed for the app to look more professional. Replacing this current view with something else will allow me to learn about the UITableViewController in iOS.

As with everything I have learned so far, I seem to immediately expect iOS to have a similar control and functionality to .NET. I think that has probably done me a disservice by assuming something new will be similar to something I already know. Most of what I have learned to this point share aspects of what I know, but are almost never exact matches. UITableView I expected would likely work like either a listview or a repeater, and it has some similarities, but it also has some quirks that I find odd. At least based on the tutorials I looked at, you don't just bind a collection to the View and then know that you will have 1 record of that data for each row. Instead they have you define the number of rows to show and how many sections you will have. These values could be, and in the demos are, just hard coded numbers that don't need any relation to the data you are showing. I guess by only looking at counts could be more efficient than entire collection, but given that once you start using real data you are going to be using the count of that collection anyways I don't see why it doesn't just use the data.

Moving on. The view now knows how many sections and how many rows to display. It has a method that is similar to the .NET repeater's ItemDataBound method. It gets called for each row, and gives you the index of the row you are currently on. Typically then you would grab the item from your collection at the same index and display its data. Again, this seems like something that probably ought to just be handled for you.

I wonder if there are better techniques for the issues and I just have been finding articles and tutorials that assume the reader has no previous programming experience, or if .NET just handles things that much differently.

Reading through some tutorials have shown really poor ways to accomplish things in iOS, however I haven't found out that they were poor tutorials until after I get fed up and look for a better way. For example, one walkthrough for using the UITableView describes the "simple" approach for showing data in each cell. First you add a label to the cell. Then you add a tag, a numeric value, to the label so that you can find that label, by its rage, in the code loop for data binding. Really? So up to this point, I have been able to name controls and then refer to them in code by that name, now I have to give each control a number that will be used to find it?

Researching further I find another approach, which is at least to me much simpler and much more likely to be used with real data. You can use a subclass, and cast your cell to that subclass rather than trying to grab each control by the tag. Then within that subclass you can have properties that are your labels and other controls, which you can interact with by name. I understand wanting to make your demo as simple as possible, but just adding a subclass with named controls seems much easier than needing to make sure your tag number always match up.

Pushing forward I was able to get the UITableViewController working and displaying my data in a much nicer, more professional looking format. Perhaps I am expecting more out of the resources that I have used than I should be, or perhaps I have simply found some really poor examples and didn't know enough to realize that I should have moved on to other places. Either way I am progressing with my app, and learning more and more about iOS development as I go.


Popular posts from this blog

Converting a Large AngularJS Application to TypeScript Part 1

I work on a project that uses AngularJS heavily. Recently we wondered if using a preprocesser like CoffeeScript or TypeScript for our JavaScript would be beneficial. If our team is going to switch languages, we would need to be able to convert existing code over without much pain and we would have to find enough value in switching that it would be worth the conversion. I had read an article that stated that because TypeScript is a SuperSet of JavaScript, you could convert a plain JavaScript file to TypeScript by changing the extension to .ts and not much else would need to change. I wanted to test out this claim, so I took a file that I was familiar with, an Angular Controller, and tried to convert it to TypeScript to see how much effort it would take and then try to figure out where we would benefit from using TypeScript. This is what the controller JavaScript file looked like to start out with: ( function () { 'use strict' ; angular .module( 'app'

Interns: Taking off the training wheels

My intern team has been working for several weeks now on our new website. We have already completed one deployment to production and are finalizing our second one. We started with a plan to release often adding small bits of functionality as we go and so far that plan has been working really well. We already feel like we have accomplished a lot because we have completed many of our project's requirements and should easily be able to complete the rest giving us time to do even more than just the original requirements. One of the things I have had some difficulty balancing has been how much to lead the interns and how much to let them figure out on their own. In deciding what our team process should be and how we should allocate our time, I think it was important for me to do more leading. I saw some deficiencies in how we were currently working and brought up some ideas for how we could address them. We had moved into spending all our time just working through stories and did not

My idea for Hearthstone to add more deck slots

Recently someone asked the Blizzard developers for more slots for decks in the game Hearthstone. The response was that they are talking about it and looking into it, but no decision has been made yet. One of the concerns over adding deck slots is that it could complicate the UI for Hearthstone and make it more difficult for new players to understand. I have what I think would be a good solution to add more deck slots without increasing the learning curve for the game much if at all. First I would take a look at the current selection screen for starting to play a game. It defaults to showing the decks that are custom built by the player if they have any custom decks, and there is an option to page over to the basic decks. This basic deck screen is perfect for how I would change this process. Instead of having 2 pages of decks, 1 for basic and 1 for custom, you would just see the select a Hero screen. Then once you selected the Hero you wanted, you would see all of the decks that