Error: Whitelist rejection in Phonegap

Notice: This answer only applies for PhoneGap version 1.x and below. From version 2.x onwards, whitelist configuration is done via cordova.xml. You have to add allowed URLs into PhoneGap.plist’s (or Cordova.plist) ExternalHosts array. For example, if you want to allow access to this URL, then add as a new entry to ExternalHosts array. … Read more

Using [UIColor colorWithRed:green:blue:alpha:] doesn’t work with UITableView seperatorColor?

You need to divide by 255.0 Because I hardly ever use values between 1.0 and 0.0, I created a very simple UIColor category that does the messy looking division by itself: (from //.h file @interface UIColor (JPExtras) + (UIColor *)colorWithR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue A:(CGFloat)alpha; @end //.m file @implementation UIColor (JPExtras) + (UIColor *)colorWithR:(CGFloat)red G:(CGFloat)green B:(CGFloat)blue … Read more

Round double value to 2 decimal places

As in most languages the format is %.2f you can see more examples here Edit: I also got this if your concerned about the display of the point in cases of 25.00 { NSNumberFormatter *fmt = [[NSNumberFormatter alloc] init]; [fmt setPositiveFormat:@”0.##”]; NSLog(@”%@”, [fmt stringFromNumber:[NSNumber numberWithFloat:25.342]]); NSLog(@”%@”, [fmt stringFromNumber:[NSNumber numberWithFloat:25.3]]); NSLog(@”%@”, [fmt stringFromNumber:[NSNumber numberWithFloat:25.0]]); } 2010-08-22 … Read more

Correct way to load a Nib for a UIView subclass

MyViewClass *myViewObject = [[[NSBundle mainBundle] loadNibNamed:@”MyViewClassNib” owner:self options:nil] objectAtIndex:0] I’m using this to initialise the reusable custom views I have. Note that you can use “firstObject” at the end there, it’s a little cleaner. “firstObject” is a handy method for NSArray and NSMutableArray. Here’s a typical example, of loading a xib to use as a … Read more

Howe to capture UIView top UIView

You can take a screenshot of any view or whole screen of the iPhone app with below method – (UIImage *)captureView { //hide controls if needed CGRect rect = [self.view bounds]; UIGraphicsBeginImageContext(rect.size); CGContextRef context = UIGraphicsGetCurrentContext(); [self.view.layer renderInContext:context]; UIImage *img = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return img; } And call it like bellow… UIImage *tempImageSave=[self captureView]; and … Read more

Moving a Stick figure, anchorpoints, animation, or something else…?

My general advice: never, ever modify the default anchorPoint (0.5f, 0.5f) unless you have a really good understanding of what it does and how it helps you accomplish things. In all other cases, modify the position property. Especially if you do bounding box or radius based collision detection, modifying the anchor point is counter-productive. Let’s … Read more