Monday, November 28, 2011

iPhone | Convert UILabel to Circle

This is how you can convert a UILabel to circle:

steps:
1)Add Quartz Core framework to application frameworks

2) Import QuartzCore.h file to implementation file.

3) #define kRectArmLength 24.0 (Not necessary, as you can decide while initializing label with frame)

//Label will be a square (equal width & height)

UILabel *lblCircle = [[UILabel alloc] initWithFrame:CGRectMake(10,20, kRectArmLength, kRectArmLength)];

//set corner radius just half of the square arm length

lblCircle.layer.cornerRadius= kRectArmLength/2;

lblCircle.clipsToBounds=YES;

lblCircle.backgroundColor = [UIColor redColor];

[self.view adsSubview: lblCircle];

Wednesday, November 16, 2011

Phonegap | Whitelist rejection in phonegap compilation with Xcode

While having an other domain server based service. Our phonegap application failed with ERROR logs :
whitelist rejection in phonegap compilation
The solution is to Whitelist (allow) the host to be accessible via phonegap, to accomplish it
In Phonegap.plist file,
Add new row to External Host (Key value pair)
for value, put your host name : (SERVER.COM).
e.g.
1) ERROR whitelist rejection: url('http://localhost:XXXX/myproject/index')
Type: localhost in value column for for External Host
2) ERROR whitelist rejection: url('http://myserver.com/dashboard/mobilews.php?')
Type: myserver in value column for External Host


May be putting "*" , the asterisk as a value of the host that references an external URL , will do the trick. but not safe.
hope this helps, It works great for us :)

see my comments below for more info, as phonegap is cordova now!

Saturday, November 5, 2011

iPhone build error | Codesign failed with exit code 1| object file format invalid or unsuitable

Recently, I have installed Xcode 4.x, this have shown weird errors with existing app , and asked for a lot of change to make it compatible with new complier.
Project timelines are always important, So I reverted back to Xcode 3.2.6

Everything went Okay. But when I tried to apply ( code signing) provisioning certificates to install application into iPhone, Build Failed with error;
Command /usr/bin/codesign failed with exit code 1
with description-
{*}.app object file format invalid or unsuitable


Then I moved to the solution library of developers (stack overflow), As most of the the developers do :)
After spending lot of hours, Saw this answer by emcmanus.

sudo mv /usr/bin/codesign_allocate /usr/bin/codesign_allocate_old
sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin


Tried first command, Blindly..
My terminal CLI answered : No such file or directory!

Then, I Explored /usr/bin folder, and observed yes! It was not there. (there is nothing to keep as back up , after renaming it. Symlinking is the ultimate goal )
I run "sudo ln -s /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/codesign_allocate /usr/bin"
to create symlink.
and YES! symlink did the trick...


Excellent... Hope this will do the trick for, who is in this trap :)