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.
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.
Comments
Post a Comment