User : espinallab

Title User Language Tags Description Date
How to find the distance between two CG points? espinallab Objective C

Distance between p1 and p2:

CGFloat xDist = (p2.x - p1.x); CGFloat yDist = (p2.y - p1.y); CGFloat distance = sqrt((xDist * xDist) + (yDist * yDist));

Background: Pythagorean theorem

Edit: if you only need to calculate if the distance between the points increases or decreases, you can omit the sqrt() which will make it a little faster.

May 25, 2011
Playing and Stopping Sound Effect in Cocos2d espinallab Objective C

This is how you play and stop sound effects in cocos2d

May 24, 2011
Display a UIPopoverController espinallab Objective C May 10, 2011
Porting Over iPad game to iphone the easy way cocos2d. espinallab Objective C May 7, 2011
Cocos2d Scrolling Background espinallab Objective C April 26, 2011
Check if the user is using an iPhone, iPod Touch device espinallab Objective C April 14, 2011
Reading plist file into an NSDictionary espinallab Objective C April 14, 2011
Universal Getters - App espinallab Objective C April 14, 2011
Easy way for Checking Device Type espinallab Objective C April 14, 2011
Loading ViewController with CoreAnimation espinallab Objective C April 14, 2011
Determine device (iPhone, iPod Touch) with iPhone SDK espinallab Objective C

Here is how to determine the device type.\r\n\r\nHow to use it.\r\n\r\nUIDeviceHardware *h=[[UIDeviceHardware alloc] init];\r\n[self setDeviceModel:[h platformString]]; \r\n[h release];

August 7, 2010
Add white shadow to the text iPhone espinallab Objective C

Here is how you add a shadow to a UILabel on the iPhone.

May 22, 2010
Adding entry to AddressBook iPhone espinallab Objective C

Add the following framework "AddressBook.framework" to your project

Make sure to import these header files.

import "AddressBook/ABAddressBook.h" import "AddressBook/ABPerson.h" import "AddressBook/ABMultiValue.h"
May 6, 2010
UIActionSheet cancel button strange behaviour espinallab Objective C

01-Dec-2008 10:22 PM Tom Saxton: I looked at this bug some more, and it seems to be an issue with the tabbar.

If you call UIActionSheet's [sheet showInView:self.view] from a view controller that is a child of a UITabViewController, then the hit testing on the cancel button fails in that portion of the UIActionSheet that lies above the tabbar's view.

If you instead pass in the UITabBarController's view, then the UIActionSheet acts as expected.

NOTE: in iPhone OS 2.1 and earlier, the UIActionSheet came up from the top of the tab bar when you pass the child view, but in 2.2, it comes up from the bottom of the tab bar, and thus covers the tab view.
May 5, 2010
Adding a Search Bar to a UITableView espinallab Objective C

This might look complicated but actually it was easy than what I though to integrate. I'm using it with Core Data, but I'm sure you can use it with any data type.

April 30, 2010