Tag Archives: mobile apps

XCode 4 – Dismissing a Keyboard after UITextField input

I originally ran into this issue back in November of 2010, while writing the original version of my iCIDR tool (hey network admins, you should buy this awesome tool now, before the price goes up!).

It’s trivial to enable a keyboard and to change the button, BUT to make it go away, and then actually wire that event into your code to do something use is not as simple as I had originally hoped!

Strategy entails using the keyboards ‘Return’ key to signal that one is done. Seems useful, but only if you have a single line text input. In my case, that’s what I’m looking at, single line input, so that’s the solution I’m going to try.

First order of business is to highlight your text area (I’m only going to be addressing the text input object), and shift to the properties tab (icon looks like this: ). Change the dropdown to the ‘Return Button’ text you wish to use. I like to use ‘DONE’, so, that’s what this image shows. Oh.. and yeah, you are also getting a little sneak peak at the newest generation of iCIDR.

The tricky part is understanding that you need to make sure your ViewController’s header file is modified to implement UITextFieldDelegate.

This is how that might look:

@interface iPhoneCalculatorViewController : UIViewController {
UITextField* seeTextField;
}
@end

Now, when the view loads, the Text box in the view needs to be addressed and wired up to the Keyboard action. Even though I defined a nice fancy label name for my object, so far I’ve only found this method to address the object ID by it’s ID. I think this is pretty funky but, cest la vie. Here is where I set the tag, also in the same view organizer dialogs:

Following that I enabled viewDidLoad (boilerplate code normally commented out), created a local variable pointer to the View’s input text box, and then set a delegator to that pointer in the main ViewContoller.

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad
{
UITextField *iPhoneInputText = (UITextField *) [self.view viewWithTag:1001]; // try to locate the object with the tag
iPhoneInputText.delegate = self; // assign a delegation.
[super viewDidLoad];
}

Moving along, I had to implement the The textFieldShouldReturn method in my ViewController class. This had to be defined to execute on the abandonment of the first responder:


// Should trap all Keyboard Return Events
- (BOOL) textFieldShouldReturn:(UITextField*)textField {
[textField resignFirstResponder];
//[self calculateOperation]; // ENTRY POINT
return NO; // default return value is YES, this is changed to NO to.... (sorry, now I've forgotten!)
}

Here is the keyboard that pops up, with the highlighted ‘Done’ button.

iCIDR 2.0 - keyboard in action (still photo)

The method (BOOL) textFieldShouldReturn is now registered to get the text input object the keyboard was typing into.

Now it’s your job (and mine…) do make it do something useful!!


Support the author, buy the App!

iCIDR - David DeMartini

Mobile social networking technology – FourSquare

I noted this a couple of weeks ago, that I was starting to play around with foursquare, the mobile social networking tool. It’s primary advantage is as a Smart Phone app. I, of course, prefer the iPhone 3GS (aka The Oracle) platform for my mobile networking, blogging and just plain monkeying around.

One of it’s features, is the ‘Stats’ page. It gives you a rundown of how often you’ve used the app, what cities you spend the majority of your time in, how many check-ins you average on each day of the week. Anyhow, here are my stats (as of this morning). It’s just and example.

My foursquare stats - Easter Sunday 2010

But, it turns out that it’s much more than a neat tool for big-brother to keep an eye on your travels (frankly, they already know where you phone is 24×7, heck, they can even turn on the microphone and listen to you without you’re knowledge, so you tin-foil that types can just simmer on down), I’ve found that it’s one of the most useful, real world source for finding places and things to do, while traveling, or just putting around your local area!

The way it works is very simple. Using the geoLocation capabilities of your smart phone (now I’m assuming your phone is actually smart.. and can do this) it will show you venues nearby that people have entered into the system. But the real benefit comes for the following three neat features!

iPhone foursquare app - Nearby Venues

1) – Displays nearby locations

Based on your location, it will display all sorts of businesses, parks, eateries, medical facilities, you name it.

Now in my sample image here, you see an number of medical facilities, primarily because I was near the hospital when I snapped this screengrab (another thing that the iPhone is amazingly adept at doing). The list can be fairly long, or pretty short. It all depends on how densely populated the area you are in is, and how many locations people have added to the system. Even out here in the sticks, I’ve found a lot of places entered into the system, presumably by developers, since almost all of them had no previous visitors when I checked in.


2) – Tips and things to do

Now, this is the one I find the most useful! Using this, in places that I’ve been frequenting for years, I discovered some NEW businesses and interesting things to do (or eat/drink) at them. I see this as a great way to explore a new town, or even the one you live in.

Traveling, not familiar with the area? Why not try foursquare to see if you can get some good tips from the locals on things to do (or things NOT to do), places with deals, specials, whatever. This is my favorite and most used part of the app.

Now a nice bonus feature is the ability for businesses to add ‘Specials’ that will pop up on the screen that you can unlock. For instance (sorry, no screen shot here, maybe when I get into the office tomorrow I’ll add that one) the hotel next to my work offers a free coffee in the morning and a $20 off certificate on a future stay, simply by checking in there using foursquare and showing it to the barrista in the lobby! See, you really can get something for (nearly) nothing!


iPhone foursquare app - ToDo List

3) – ToDo lists

This is sort of an extension of Feature 2, but I think it’s useful enough on it’s own to be mentioned.

It’s another neat feature that comes in handy for a traveler. Did you hear about something cool to do on foursquare (a tip) and want to recall it next time you are in the area? Mark it as a ‘To Do’ and it will show up on your list. Simple as that.

“Big Deal!”. you might say,“I can do that with a notepad!”. True enough. BUT, you use the foursquare website to poke around in another city location, look at the tips and remember the ones you think sound interesting, by simply clicking and adding to your ToDo list. And guess what, when you are in the local area, the relevant list items are right there at your fingertip. Seems easy enough!

Final thoughts for today – monitization

Being the semi-paranoid data geek I am, what I don’t get about this application, is how the developers and the operator of the website make their money. I can see where a business might pay a little to offer a deal, but how much $$$ is there, for foursquare, in that? I don’t know. Now I also wonder if they are using this neat pile of data they are collecting on your, and re-selling that to potential marketeers! That would be my biggest concern. And one that I’ll be looking into soon.

For now, it’s fun little app. And honestly, it sort of encourages me to get out of the house more and explore places, looking for things people suggest in the tips.

Unless you are one of those tin-foil hat types, you might check it out.