Sunday, January 17, 2010

Text Fields and dismissing the keyboard

I was going back and making changes to my text fields and keyboard dismissing and wanted to move to the next field only if that field was blank. I relized then, that I had not taken any notes here on how to dismiss a keyboard, or how to assign a new text field. Here is the code to dismiss a field, and then assign the next one. I'll just write some if statements to figure out the order in which I want them to populate if the user needs to enter them all.

- (BOOL)textFieldShouldReturn:(UITextField *)theTextField {

if (theTextField == userName) {

[userName resignFirstResponder];

[userPassword becomeFirstResponder];

}

if (theTextField == userPassword) {

[userPassword resignFirstResponder];

[serverAddress becomeFirstResponder];

}

if (theTextField == serverAddress) {

[serverAddress resignFirstResponder];

}

return YES;

}



Ok, I wrote the if statements before I even finished writing this blog. It's messy, so if you know a bette/faster way to do this, do it your way!


- (BOOL)textFieldShouldReturn:(UITextField *)aTextField {

if (aTextField == userName) {

[userName resignFirstResponder];

if ([userPassword.text length] == 0) {

[userPassword becomeFirstResponder];

} else if ([serverAddress.text length] == 0) {

[serverAddress becomeFirstResponder];

}

}

if (aTextField == userPassword) {

[userPassword resignFirstResponder];

if ([serverAddress.text length] == 0) {

[serverAddress becomeFirstResponder];

}

}

if (aTextField == serverAddress) {

[serverAddress resignFirstResponder];

}

return YES;

}

Thursday, January 14, 2010

Working with SQL Databases on iPhone

I'm using a small sqlite database for my iPhone app and was having problems with the data. I was making changes to the database in either CLI or in Firefox SQLite Manager, deleting the database file from my iPhone project, and copying the new file in. It would never use the new data, only the old data was being accessed. I finally figured out what was going on because there was not enough rows when I was stepping through it and set out looking for an answer. Below is the first hit I found and it answered it perfectly.

Short answer: It get's cached like data for a normal application. Go look in your folder for the iPhone Simulator/USR/Applications and you will be able to delete it from there. Then compile your code again and it should be working.

Monday, January 11, 2010

Refreshing views while using a Tab Bar on the iPhone

In my tab bar based iPhone application I had a view that would connect to a web service and pull down the requested data. It would then use that data to populate labels and text fields on other views. I had it working for the first time using "- (void)viewDidLoad", but was not able to get it to update when I would go back to the main view and refresh the information.

I finally found that the viewWillAppear method just didn't have a place holder but I could add it and use it. So, just add the following code to the .m file controlling your view and it will update every time you switch back to it.

- (void)viewWillAppear:(BOOL)animated {

// Do stuff here

[super viewWillAppear:animated];

}


Thursday, January 07, 2010

Handling iPhone errors part two

Now that I can make a pop-up message I wanted to clean up the code and do all of my error processing from one place. To this end I removed all of the error handling I was doing and instead changed it so my individual functions would return a value. The number 0 if everything was ok, and a number that would signify the error type if everything was not ok. I had about 15 possible errors at the time so I gave them all numbers and converted my functions from -(void) to -(int) and added the numbers to the return lines. Below you will see an example of the code and how I'm now processing the errors. Everything works fine, but if there is a better way to do this, please let me and everyone else know.

// Header file

- (IBAction)refreshInformation:(id)sender;

- (int)verifyUserInput;

- (void)handleErrors:(int)errorNumber;


// Call the function to check user input, and then pass the results to the error checking //function

- (IBAction)refreshInformation:(id)sender {

NSInteger funcReturn = 0;


// Verify they have entered everything we need to get the information

funcReturn = [self verifyUserInput];


// Did we have any errors?

if (funcReturn) {

[self handleErrors:funcReturn];

}

}



// Function to check the user input

- (int)verifyUserInput {


// Initialize some local variables with the input from the user

NSString *nameString = userName.text;

NSString *passString = userPassword.text;

NSString *serverString = serverAddress.text;

// Verify that people are putting the right stuff into the fields

if ([nameString length] == 0) {

return 11;

} else if ([passString length] == 0) {

return 11;

} else if ([serverString length] == 0) {

return 11;

}


return 0;

}


// Function to process the error numbers

- (void)handleErrors:(int)errorNumber {

NSString *errorText;

switch (errorNumber) {

case 11:

errorText = @"All fields are required";

break;

case 21:

errorText = @"Authentication failed";

break;

case 22:

errorText = @"System login failure";

break;

case 23:

errorText = @"Read-Only user required";

break;

case 24:

errorText = @"Network connection failed";

break;

}


UIAlertView *error = [[UIAlertView alloc] initWithTitle:[[NSString alloc] initWithFormat:@"Error: %D", errorNumber]

message:[[NSString alloc] initWithFormat:@"%@", errorText]

delegate:nil

cancelButtonTitle:@"OK"

otherButtonTitles: nil];

[error show];

[error release];

}


Wednesday, January 06, 2010

Handling Errors on the iPhone

I read that you need to have a popup error if your application can't get to a network and it's required, so I did some quick checking on how to do that and here is the code I found. Very simple to use and modify to add specific errors. Just place this into a function and call it, or put it right into your code where an error occurs.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Error"

message:@"This is the error or get a string"

delegate:nil

cancelButtonTitle:@"OK"

otherButtonTitles: nil];

[alert show];

[alert release];


iPhone TabBar icons



Happy New Year everyone!

As with all fun projects, I've taken a new tactic at how to do my iPhone application. It now includes a tab bar at the bottom for switching between pages. I now had a new problem. All of the icons were coming up as grey blobs in the bar and it took me a while to figure out how to fix it. I never really found a good answer on the internet, so it's my own info here (not a link like normal).

I found that the icons should be 30x30 pixels and should be in grey scale. I also have found that anything that is colored shows up as a light grey. It doesn't seem to mater if this is white, grey, black, etc. Everything else should be transparent and that will will show up black.

The pictures above are black lines on a transparent background.

-Tige


Friday, December 25, 2009

Fliping between pages on iPhone

For my project I wanted to have an info screen (really, I did!). After some looking around I found a great video tutorial on how to do this. I creates a separate nib (.xib) file and loads it based on pushing buttons. It also incorporates accessing variables in other .m files which will be useful to me sooner that I had though now that I know it's easy to do.

The only word of caution on the video is that is a little dated and Apple has made some modifications to the way both the IB and xcode work. Specifically, it does things for you now. I'm a total noob to this stuff, so I'm sure the next person will will not have a problem. Just remember that it is different, and you only need to make two files, not 6. When you create the SecondView files, you can create the .h and .xib files all at once. The old xcode required you to make all three separately. IB just looks a little different is all.

Have fun!

http://vimeo.com/1450817


Sunday, December 20, 2009

iPhone image hiding

I wanted to display a little red "X" when someone didn't enter all of the fields, but was having a hard time using the .hidden label. I finally found a really good post that I'll link here, and I'll also summarize for you.

This works for UITextField and I'm sure other objects as well.

Hide an object

Here are the basics.
  1. In your .h file for your view. In the same section as @interface enter: IBOutlet UIImageView *imageBadInput;
  2. Just below the interface section enter: @property (nonatomic, retain) IBOutlet UIImageView *imageBadInput;
  3. Now move to the .m file for you view and after @implementation enter : @synthesize imageBadInput;
  4. In the body of this file enter the following to hide the object, and use the NO form to display it: imageBadInput.hidden = YES;
  5. Save these files (they will be grey in the list on the left if they are not saved).
  6. Open up Interface Builder with your nib (.xib) file. Ctrl-click and drag either the File Owner, or the ViewController (depends on how you are building your app).
  7. Drag the blue line over to the graphic you want, and drop it once highlighted.
  8. You now have the option to select the outlet you created in step 1
  9. If you have created several of them, they will all be available. Objects already connected have a "-" before them.
  10. Save the nib file, and build as normal.
If you want to hide these objects unless there is a problem, you can implement this in your views .m file to hide the objects when the view loads.

- (void)viewDidLoad {
imageBadInput.hidden = YES;
}

Thursday, December 17, 2009

iPhone dev learning all the time

Here are a few things I learned today.

How to exit out of a function. "return;" though one I know.

How to move from one textField to another textField for input using the Next button on the keyboard (Done and Return works also). Just put this in with releasing the keyboard "[field2TextField becomeFirstResponder];"
Thanks flexicoder for this.

I needed to use some regular expressions to find information in the server replies that I'm working with. I'm hoping to figure out how this stuff can be used with xml, but for now I'm using RegexKitLite Framework. Seems to work well, and it's just a .h and .m file to add to the project.


Saturday, December 12, 2009

iPhone XML interface application - Part 1

I'm building an iPhone application that will interface with some networking equipment to pull status data and display it on the screen. The basic components (I think) of this are using http POST, managing a cookie, and reading the xml output from the POST command. I also need to enter a small amount of data in on the phone (server, username, password) so I need to learn how to do some of those things as well.

Some of the things I'm working on so far are:

1. Taking the text input (server url address) on the iPhone and forming that into something to make the actual http query/POST.


2. A framework for working with HTTP that includes POST.

Long time since last update..

The house didn't get built. Long story, so I won't go into it.

On to my next project. An iPhone application. I finally found a use for one that someone has not already built. I need to learn a lot about iPhone apps on top of objective C. Fortunately, my C background from years ago is mostly applicable, and what I want to do is not rocket science. I keep finding tutorials etc. that I want to keep track of, so I'm going to use this blog to do that. If it only get's referenced by me, so be it. If someone finds the information useful, then that's just great.

Tuesday, September 04, 2007

Lot videos

Videos of where the house is going on the lot.





Friday, March 09, 2007

Infiniti Power Parachute - Low and slow

A few minutes of our Infinity Power Parachute on it's first day of flying since we purchased it. It's a clowdy day, but almost no wind so we were able to take it up and fly aroudn a bit. Kept it low so as not to get lost in the clowds. Some nice tight turns very close to the ground. We were below the tree line for much of the flights.

keywords: buckeye dream machine six shooter chute fly

New Years 2007 Sleds

Mostly snowmobiles jumping near a ski resort Mt. Bachelor out of Bend, Oregon. Five of us just having some fun till the day got cut short when one of the sleds died on us. Captured The day before New Years eve 2006. All video from our Helmet Cam, Don't Stay by Linkin Park playing for audio. Arctic Cat (900 and 1000), Ski Doo (550 and 1000), and Polaris (700 and 800) all on the ride. Extra Keywords: snow machine, snowmobile, sled, jump, OR

Sunday, September 10, 2006

Charlie's 450 ATV wheelie to crash

Charlie on his Honda 450 quad riding a nice wheelie on the flats of the Florance, Oregon sand dunes over Labor Day weekend 2006. As we start to overtake a sand rail he get's on it a little too hard and goes over the back. Further inspection found left front and right rear tires off the rim and the left front arms smashed. In the video you can see the bike turn sideways before it comes down. Charlie was fine other than taking a beating from his wife when we got him back to camp.

See it on Google Video at: http://video.google.com/videoplay?docid=-2603876273462024871&hl=en

-Lane

Thursday, August 31, 2006

Project = New Home

It's time to move. Not just move, but build a home and move. This will be a challenge because my wife claims she won't help, and I'm at work most of the time. So, where to start?

First, you go find some property. Done.
rmls.com

Second you need some house plans. Done. The plans we selected suited our needs perfectly. We wanted a home with the kitchen next to the garage, master bed on the first floor, big bonus room over the garage, and the upstairs bedrooms on the opposite side of the house from the master bedroom. A few other factors were a office, and an individual bathroom for a large bedroom upstairs (Daughters idea).
Cool House Plans

Third... I honsetly have no idea...

So this is what i'm going to do. Since I have no idea what to do next I'm going to write it down as I go. That way some other poor sole like me won't have to do it the painful way.

I actually need to wait a month or so to purchase the property so until then I don't need to worry about financing this thing. I'll get to options on that when it's time.

I'm building in an area that is being developed. Based on this I'm going to build a house this is both larger and more extravagant that I need or want. Basically because I want it to fit in, and be worth a bunch of coin when I'm done with it. To that end I'm going to look for things that will class the house up and make it more desierable to the upper crust.

As I go through this I'm going to put links and probably pictures in here. Please note that I don't own any of these things and they will be used as an example of the type of item I want. So, while I may post BrandX water faucet, I'm probably refering to the style of faucet and not BrandX.

I'll post again soon when I have some ideas on what to put in the house. A few of the first items I'll be looking for: Steam Room for the master shower. Music throughout the house. Tankless water heater (propane). Instant hot water in the bathrooms (via a pump).

That's it for now, take care!

-Lane

Wednesday, August 30, 2006

Update

So it's been a while since my last post. I'll catch you up on things.

Mythbox = Going well still. I'm starting to put the pieces together for another machine. This one will be for the new Panasonic 42" plasma I got a month ago. It's nice... TH42PX50U

MAME = Well... The wife put the beat down on me for wanting to build a cabinet. In all honesty she was right and there really is no room in our house for the thing. I did get a 25" TV and had it setup for a while on a desk. My daughter and I managed to kill quite a few bad guys together and had a lot of fun doing it.

What's next: Well, I hooked the MAME computer up to the new plasma until I can get a real MythTV box going. I'm running 3 channels of 802.11g in my house so I have 1 for work (secured and hooked to a VPN) 1 for the main MythTV box downstairs, and the last one for the windows box connected to the plasma. I've done this because I can run wires to either of those. Well, without a bunch of hastle anyway. Right now I'm both streaming video to the MAME computer and copying TV programs over. I use one channel for one connection, and 1 channel for the othehr. This way I don't have both hops on the same frequency and I get much better throughput.

Ok, that's it for the update on the in home machines. I'll update this info when I finally get the parts in for the new MythTV box.

-Lane

Wednesday, April 13, 2005

April 13th - It begins.

So it begins. I have no idea what I'm doing, but I giured wince I saw the Blog thing in Google I would give it a shot. If nothing more I can always just use this as a way to write my thoughts for the day. It's been told to me that you should always be writting down your thoughts. I'm not sure why you would want to do this. It probably has something to do this exercising your brain and getting the thoughts on paper. This would make them real and cause you to appriciate the ideas better now that they are real.

So, since I'm suposed to be writting let's put down a few things I'm working on so I can see it written and absobe the magnitute of what I need to get done soon.

Home
1. I have just upgraded my MythTV box to the latest version of Knopmyth. R5A12. Install was fairly easy considering I have a PVR-350 video card and I'm using the TV out. If you don't know what mythtv is, it's a free Linux based PVR. Lot's of functionality and the ability to put other types of media files on it and play them. Or, take the shows that you record and watch on another mythtv box or on your computer. http://mysettopbox.tv/knoppmyth.html

2. Working on a Windows based MAME box. I'm also adding pinball to the mix. What's MAME? MAME is an emulator for the old arcade games. Basically if you own or purchase the ROM files you can play PacMan on your computer and it will be the original PacMan you played when you were a kid. Every game I could think of I have found. The best part of MAME is that people have built hardware that you can use to actually have a real arcade joystick and buttons. I have already purchased part of the hardware I need and built a desktop box with two player stations. I'll try to post a picture soon. I just built it as a prototye so it's a little cheesy.

Take care everyone! -Lane