August 31st, 2009 | CSS, Debugging, Web Development, ie6
A Frequent Problem with ie6: The bottom of the text (e.g. g y p) get cut off and make text illegible. This mostly happens with two line breaks and can be fixed by using a larger line-height in css.
To fix the problem we are going to create a class using the internet explorer 6 box hack.
We need to locate the exact area that we are having the problem with. For me the text was being cut off at .description h4 a
* HTML .description h4 a {
line-height: 1.2em;
}
To fix the text cut off issue without the box hack just simply created a css class and adjsut the line-height
p { line-height: 1.2em; }
August 29th, 2009 | XCode, iPhone Apps, iPhone Development
After updating the iPhone in iTunes to Software OS 3.0.1 I was unable to access it through the xcode organizer. After reinstalling the newest xocde (failed) and some digging I found a line of code you need to copy and paste into your terminal once, restart xcode, and you have access to pushing onto the iphone again.
Open up Terminal, copy below, paste and enter into terminal, restart xcode.
ln -s /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0\ \(7A341\) /Developer/Platforms/iPhoneOS.platform/DeviceSupport/3.0.1
August 28th, 2009 | CoreData, Debugging, iPhone Apps, iPhone Development
One of my CoreData applications started acting buggy, and was spitting out a huge error dump on app close in the debug console. The errors spitting out didn't tell me anything but CoreData Error 1560 and 1570. Upon inspection I found on google that another layer of errors is stored in the CoreData foundation. On Stack OverFlow found a very useful function but re-wrote it because
![[survey managedObjectContext] save:&error]
was causing an error.
Add this into you applicationWillTerminate function in your Application Delegate
/**
applicationWillTerminate: saves changes in the application's managed object context before the application terminates.
*/
- (void)applicationWillTerminate:(UIApplication *)application {
NSError* error;
if(![[self managedObjectContext] save:&error]) {
NSLog(@"Failed to save to data store: %@", [error localizedDescription]);
NSArray* detailedErrors = [[error userInfo] objectForKey:NSDetailedErrorsKey];
if(detailedErrors != nil && [detailedErrors count] > 0) {
for(NSError* detailedError in detailedErrors) {
NSLog(@" DetailedError: %@", [detailedError userInfo]);
}
}
else {
NSLog(@" %@", [error userInfo]);
}
}
}
The original post can be found here
The cause of Error in my CoreData Application was an Attribute in my xcdatamodel file. An optional field was checked as indexed and not optional. The simple action of unchecking indexed and checking optional fixed a whole mass of errors.

August 26th, 2009 | How to, UINavigationBar, iPhone Apps, iPhone Development
A quite useful button for a navigation controller with a deep stack would be a home button. It is simple to add.
In your RootViewController viewDidLoad Function
- (void)viewDidLoad {
[super viewDidLoad];
UIBarButtonItem *homeButton = [[[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Home", @"") style:UIBarButtonItemStyleBordered target:self action:@selector(goHome:)] autorelease];
self.navigationItem.rightBarButtonItem = homeButton;
}
That will add a home button in to top right of your navigation controller
Create a function called go home in your rootViewController
// return to root view
- (void)goHome:(id) sender {
[self.navigationController popToRootViewControllerAnimated:YES];
}
This function will pop your view controller to its root view
August 25th, 2009 | Form Validation, UITextField, iPhone Development
An iPhone Application we recently produced had a order form on it. We needed to create a function that would run through all our UItextFields, extract their values, loop through, alert the user if a UITextField wasn't completed, and execute a function (our ajax request) if all checks out.
What 's involved in this function
- alertview - a pop up that lets the user know they missed a required field
- array - a list of all the UITextField values
- int - a variable that increment everytime time a UITextField Checks out
- for loop - Loops through the Array
- if statement - Check the array count to the increment count
This function assumes you know a bit about the iphone, have declared and linked your IBOutlet UITextFields, and have linked your submit button in the Interface Builder to -(void)textFieldCheck:(id) sender; (which would be declared in your header file).
-(void)textFieldCheck
:(id) sender
{
// Declare your Alert, NSArray, increment int
UIAlertView
*alert
= [[UIAlertView alloc
] initWithTitle
:nil message
:@"Please Fill in All Required Fields." delegate
:self cancelButtonTitle
:@"OK" otherButtonTitles
:nil];
NSArray *fieldArray;
int i
= 0;
// Load up our field array with the UITextField Values
fieldArray = [[NSArray arrayWithObjects:
[NSString stringWithFormat:@"%@",orderName.text],
[NSString stringWithFormat:@"%@",orderPhone.text],
[NSString stringWithFormat:@"%@",orderAddress.text],
[NSString stringWithFormat:@"%@",orderEmail.text],
[NSString stringWithFormat:@"%@",orderQty.text], nil] retain];
// loop through the array, alert if text field is empty, and break the the loop, other wise increment i
for (NSString *fieldText in fieldArray){
NSLog(fieldText); // make sure all is reading correctly in the console
if([fieldText isEqualToString:@""]){
[alert show];
break; // break out!!
}
i++;
}
// check that all the field were passed (i == array.count) if so execute
if(i == [[NSNumber numberWithInt: fieldArray.count] intValue]){
NSLog(@"Its all Good"); // some console fun
[self sendOrder]; //where you execute your request function
}
// release it all
[alert release];
[fieldArray release];
}
August 25th, 2009 | UITextField, iPhone Development
When dealing with user form, I was looking for the best way to form check. Coming from a web background, I'm used to doing it with javascript/ajax requests. In an if elseif statement that activate a button with all input field are not !== ""
To access the inputed iphone text from a uitext field:
myUITextField.text
To compare that input text to a string
[myUITextField.text isEqualToString:@"This String"]
I'm starting to fall in love with apples objective-c in the xcode environment, Apple got it right.
When the the form checking is complete we will post the code.
August 24th, 2009 | iPhone Apps, iPhone Development
PNG's kick ass, that being said, sometimes JPGs are smaller when compressed. Below is an except from Addison Wesley's iphone cook book.
"Xcode automatically optimizes your PNG images using the pngcrush utility shipped with the SDK. (You’ll find the program in the iPhoneOS platform folders in /Developer. Run it from the command line with the –iphoneswitch to convert standard PNG files to iPhone- formatted ones.) For this reason,use PNG images in your iPhone apps where possible as your preferred image format."
Now go batch resize your image catalogs into PNG format, now.