Combining multiple UITextFields and a UITableView in a nice way for an iPhone app: part 2

My last blog post was about creating a form for an iPhone application by combining multiple UITextFields in a UITableView. I outlined the problems with this kind of screens. The first problem is the destruction of data already entered when scrolling the field off screen and secondly, app crashes when the field with focus is scrolled off screen and you touch inside another textfield. The solution I proposed was to nest the UITableView inside a UIScrollview. After receiving feedback I came up with a second solution:

  1. extend a UITableViewController instead of implementing UITableviewDataSource and UITableViewDelegate yourself
  2. disable reuse of cells by using a unique cell identifier:
  3. NSString *CellIdentifier = [NSString stringWithFormat: @"Cell%i", indexPath.row];

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {

    cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];

    ..

    }

The UITableViewController handles scrolling into view when the keyboard is shown quite nicely. Using the unique identifier will prevent a cell and it’s content to be reused. And I had to agree to some of the feedback: using a UIScrollView to nest a tableView is kind of a hack.

There is a down side to this: UITableViewControllers don’t like to be combined with other view controllers, so you have to use a NavigationController or TabBarController to offer further interaction possibilities. I tried to, but never managed nicely to have for instance a UIToolBar over the UITableView.

Try it out and let me know what you think!

Download XCode project TestTableViewWithKeyboard2 with demo using UITableView to create a form.

Combining multiple UITextFields and a UITableView in a nice way for an iPhone app

Update: also read Part 2 explaining a different way of solving this problem.

So a decent number of iPhone apps will not only show things like data, but also offer you the possibility to edit data. Many controls like UISlider, UISwitch and UITextfield are provided by Apple to create some type of edit screen, almost like a web form on a HTML page. Creating a simple form that only covers the top half of your screen is simple: you create your elements like UITextField at the top, and when you touch inside the field the onscreen keyboard will show up. You hit a Done Button or a non-UITextField control and the keyboard disappears again.

Now, when you have more data to add/edit than will fit in half a screen, things get more daunting:

  1. the keyboard should only be visible when editing a UITextField
  2. when touching a UITextField so that the keyboard becomes visible, it should not cover the field you are editing
  3. with the keyboard visible you should still be able to scroll to all elements of your editing form, and not have parts be covered indefinitely by the keyboard

Well, the most natural kind of view to use to display all controls is a UITableView. Apple uses it herself, look at the editing screen for your Mail.app settings. But when you just throw in a UITableView, you run into problems:

  1. when scrolling off screen, table cells are reused and therefore also its subviews like UITextFields, which causes your newly entered data to be destroyed
  2. when having a UITextField being firstResponder (cursor in it),  you scroll it off screen and the touch inside another UITextField that then becomes firstResponder, your app will crash. This is problably because the first UITextField is destroyed before it can resignFirstResponder

So how do we do this then? Apple does use a UITableView in some way, but the above problems are show stoppers. Well the answer is: use a UITableView, but don’t let it scroll.

Continue reading

Iphone OS 3.0 announced

Yesterday Apple held meeting to announce the new upcoming version of their Iphone OS, version 3 (we’re now at 2.2.1), to be released somewhere this summer. Already days ahead was a buzz going on, with lot’s of people making lists of new features they thought/wished were added to the already popular platform.

Major awaited features were cut/copy-paste, Flash, background processes, MMS, tethering (using your phone as a modem to your laptop), wireless keyboards, better app organisation

Majority of new features are indeed implemented. Cut/copy-past is there in a nice fashion as is MMS and tethering. Flash is still at large, Adobe and Apple are trying their best to solve the technical issues. Background processes are not there, but instead Apple opted for Push notifications. This will allow a service to push a short message (alert, text, audio) to an application without the application being running. Wireless keyboards and better app organisation is still missing.

What is also interesting is the new payment models. Now, you could only charge per download. Added to this will be 3 new models: subscription to apps, purchase of additional content (great for media companies) and purchase of additional levels (great for gaming apps). This means you can also purchase new things from within the apps.

What is most interesting to me?  The push notification! I am working together with partners to create a messaging solution with a big focus on mobile. As third party apps, as opposed to the standard Mail.app on the Iphone, cannot run in the background with 2.0 it’s quite difficult to go head to head with Mail.app. Push notification will change that. As this services goes through Apple services, I am quite curious what they will charge though.

Other new features that were not so much anticipated are Search (through Spotlight), landscape keyboard, Google Maps libraries for third party apps.

I downloaded the beta SDK already, but unfortunately Apple doesn’t allow any disclosure of information or screenshots:( I honoustly hope they don’t make the mistake that they made with 2.0 again, to lift this NDA so late that no publisher dares to invest in publishing an Iphone 3.0 development book. Go over to Crunchgear to see some screenshots (while it lasts).

OS 3.0 will be available this summer, and downloadable for current Iphone and Ipod touch users (Ipod users have to pay 10 USD). So you don’t have to get a new phone to be able to run 3.0, which is great. Big question: at what speed will users upgrade their OS, and will any (major) problems arise. 

You can watch the full presentation here at the Apple site.

More reading about Iphone OS 3.0:

Battle of mobile platforms is taking off

After Apple launched the Iphone 3G last summer, T-mobile will begin rolling out the Android platform in The Netherlands. Within weeks the HTC G1 will be available (the phone has been out in the USA since October and in the UK since November). And now, to the surprise of the whole industry Palm made a strong comeback with the Palm Pre, running their brand new OS called webOs. It has been announced at CES just last week, but yet has to get reviews and into the market.

So, it seems that we have at least 2 strong players with an outsider (Palm) ready to bring mobile computing to the next level, and really change that thing in our pockets and hands into a computer with a small screen instead of just an apparatus to call and text with. It’s not about that anymore, it’s about all the applications that you can run on.

What will determine the success of these platforms?

  • user experience: usability, seamless integration, slick looks: Apple with having one device, one manufacturer has controls hardware, OS, store has created a complete package with eco-system around it. And of course it’s experience with good user interfaces and design for Mac and Ipod has given it a head start. Android is not a complete deal but a platform, that hardware manufactures have to run on their phones that will come in many shapes and forms.
  • good apps that can easily be purchased:
    • developer support: good language and good tooling. Apple offers Objective-C with a number of UI libraries, together with their IDE Xcode. Android is for 95 % Java, that is supported by Eclipse plugins. This means that all those Java developers out that can start creating Android apps in no time, while much less Objective-C developers are out there. Learning Objective-C and XCode will take some time for developers from other platforms.
    • easy app stores to browse, look, buy and download applications. Apple’s app store has already proved to be a success. Android’s app store has yet to kick in. Maybe multiple app stores will become available, that certainly will be more open but also more fragmented than Apple’s.
    • the creation of an ecosystem that makes it profitable for developers to create apps for a platform is crucial for turning phones into a mobile computing platform. Until now the Apple app store has been a success, offering free and paid apps. Selling an app is just submitting the app to the store, although Apple has rejected apps for unclear reasons. This means that you do not know if your investment will make any money untill you submit the app, which is definitely a bad thing. Also installation of apps should not be limited by telco settings or anything.
  • good availability of devices. For now Apple has chosen to sell the Iphone in most countries only together with a subscription plan with a mobile operator. For instance, if you are with Vodafone.nl but want an Iphone, you’re stuck. Of course the device is expensive (you can get it simlock free in Belgium for 650-700 EUR), but why not let users buy it simlock free? Android devices when on the market will soon be available in all kind of forms, and with or without subscription packages.
  • pricing: Apple is and will always be a brand that focuses on quality and less on competing on price. Android is open source and free, so let’s see if any manufacturer will create a cheap but powerful Android phone.

And oh yeah, where are the mobile manufacturers? Nokia, Motorola, Ericsson? Motorola apparently is getting ready to move over to Android.  Nokia still hangs on to Symbian, but that OS never got the leverage Iphone OS and Android seem to get. It will take a while though before Nokia admits that Symbian is dead, and that is has to switch over. So apparently it took computer companies to move over to the mobile industry to really make phones a success as a computing platform. Let’s hope they do not turn Android into a fragmented market that brings no value to end users and developers.

More reading:

T-mobile subscription plans with Iphone 3G for Netherlands

The Netherlands is one of the last countries to get (legitimate) access to Iphones. Of course, as the first generations lacked UMTS support nobody was bothered by that. But now on july 11th T-mobile will start offering Iphones in The Netherlands.

As their press announcement is in Dutch and Euro, I thought let’s translate and convert also to USD. Below are the prices in Euro and USD, assuming 1 euro = 1.48 USD, and 2 year contracts.

SMS = short message service = text message for you americans.

minutes SMS price/m () $ 8GB model () $ 16GB model ()  $
150 150 29.95 44.33 79.95 118.33 159.95 236.73
300 300 44.95 66.53 1 1.48 79.95 118.33
500 500 64.95 96.13 1 1.48 19.95 29.53

Including unlimited Internet usage (2048/384 Kbps), Visual voicemail.

It seems a good deal compared to the AT&T pricing :

“iPhone 3G will be available for $199 for the 8GB model and $299 for the 16GB model. These prices require two-year contracts”

Engadget has a better overview.

And even the subscriptions aren’t that expensive compared to normal no-phone T-Mobile NL subscripton plans:

Plan minutes Price/m Price per minute Price per SMS
Relax 100 100 € 14,50 € 0,15 € 0,25
Relax 200 200 € 24,50 € 0,12 € 0,25
Relax 300 300 € 34,50 € 0,12 € 0,25
Relax 500 500 € 49,50 € 0,10 € 0,25
Relax 1000 1000 € 94,50 € 0,09 € 0,25