27/08/10
iPhone icon rounded corner exact radius
This might be usefull for all those designers who want to create great fancy application icons.
The exact radius for the icon rounded corners is:
- iPhone OS 3.x(57×57) is 9 pixels
- iPhone OS 4.0(114×114) I guess it’s 18 pixels but I’m not sure of that
The exact radius for the Artwork(512×512) is 80 pixels.
25/08/10
Zooming an image using UIScrollView
To add the zooming in the scrolling part you can do this by following these steps:
1. Make the MyViewController a UIScrollViewDelegate. Do this by adding
2. Create a UIImageView instance variable in the @interface of MyViewController. We will need this to specify it to the Delegate which object is to be zoomed. Add the @property and @synthesize for this image in relevant places. I used scroll2ImageView as the name of the instance.
3. In the viewDidLoad Method in myViewController.m class replace the code for setting up scrollView2 with this code.
[scrollView2 setBackgroundColor:[UIColor blackColor]];
[scrollView2 setCanCancelContentTouches:NO];
scrollView2.clipsToBounds = YES; // default is NO, we want to restrict drawing within our scrollview
scrollView2.indicatorStyle = UIScrollViewIndicatorStyleWhite;
scroll2ImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"image0.jpg"]];
[scrollView2 addSubview:scroll2ImageView];
[scrollView2 setContentSize:CGSizeMake(scroll2ImageView.frame.size.width, scroll2ImageView.frame.size.height)];
scrollView2.minimumZoomScale = 1;
scrollView2.maximumZoomScale = 3;
scrollView2.delegate = self;
[scrollView2 setScrollEnabled:YES];
We made three changes here. First we replaced the local instance of imageView with the class instance scroll2ImageView. We will need this in the next step. Second we added min/max zoom scale for the image. Third we assigned the scrollView2 delegate to self.
4. Last thing we need to do is tell the delegate wat all to zoom when it detects a zoom in/out pinch. We add the following method for this.
-(UIView *) viewForZoomingInScrollView:(UIScrollView *)scrollView {
return scroll2ImageView;
}
16/07/10
New iPhone App: Uterqüe
Today a new fashion brand trust in our services. We develop a new iPhone app for Uterqüe, under Inditex license. We’ve worked closer with our client Abuse to make them a completely success.
This app is a pocket catalogues of all the products that can be found in each Uterqüe store, organized by sections which is very useful for all customers, but one of the most important features of the application is the update frequency: Uterqüe’s team will update the content weekly to keep you informed about all its new products.
Now the user can use a Augmented Reality or Google maps functionalities to search his closest store.
I would like to take this post to talk about mobile marketing posibilities, there is a lot of companies around the world using mobile marketing solutions to promote their products. iPhone and large set of latest mobile devices has the multimedia capabilities to provide a very easy, clear and useful channel of communication between companies and it’s potential customers.
The fact of Uterque releasing a set of applications available in most important plattforms(iPhone, Android, Nokia, Blackberry,…) it’s just another example of how useful can be for the companies to keep his customers updated with it’s latest products through a maketing mobile application.
07/07/10
How to programatically load nib files
A few days ago I was asked if it’s possible to load nib files programatically without being loaded and initialized from UIViewController’s initWithNib… message.
I didn’t knew the answer at this moment but once I got to the office I decided to look for it. After a few minutes googling I found the answer: it’s possible, and here is the source code to do it.
NSArray *topLevelObjs = nil;
topLevelObjs = [[NSBundle mainBundle] loadNibNamed:nibNameOrNil owner:self options:nil];
if (topLevelObjs == nil)
NSLog(@”Error! Could not load nib file.\n”);
02/07/10
How to change MFMailComposeViewController’s title
There are a lot of things in the iPhone SDK that should be easy to do but they are not, and this is one of them. Changing the Mail Compose View Controller title should be as easy as:
[myMailComposerVC setTitle:@"My title"]
but if you do that you don’t get anything, you still get the “NEW MESSAGE” text.
The way I found to access it is the following. Maybe there is another/better don’t know but this one definitely works:
[[[[myMailComposerVC navigationBar] items] objectAtIndex:0] setTitle:@”My title”];
Hope it helps someone as much as it helped me.
01/07/10
Application icon sizes
With the new device releases the number of icons of one applicaction has incresead considerably and it’s impossible for me to remember all of them. So just in cas someone is in the same situation as me here is a list of all of them.
App Store Icon
- 512×512
Application Icon
- 114×114 iPhone 4
- 72×72 iPad
- 57×57 older iPhones
Spotlight Search Results and Settings Icon
- 58×58 Spotlight/Settings iPhone 4
- 50×50 Spotlight - iPad
- 29×29 Settings - iPad/older iPhones
Document Icon
- 44×58 iPhone 4
- 320×320 and 64×64 iPad
- 22×29 older iPhones
I found this usefull PSD in “Cocoia Blog”.
Take advantage of new retina display in your iPhone 3.x applications
There are a lot of applications in the appstore with amazing graphics that look great in the iPhone OS 3.x, but it doesn’t look so great using the new retina display of the new iPhone. A lot of them have been released as new applications again but named the same with an “HD” at the end.
You might wonder if that is because there is no easy way to build an application with both HD graphical assets and nonHD graphical assests that looks great on all iPhone OS versions. But that’s not true. Recently I found out a very esy way to do that:
UIKit supports the automatic loading of high-resolution variants (@2x) of your images.
The “only” thing you have to do is generate HD graphical images of each existing image in your current project and name it the same but with an @2x in the end. i.e:
- previous image name: logo.png
- HD image name: logo@2x.png
once you have all the images just import to your existing project and compile it again using the same iPhone OS version you used to compile the nonHD version of the application, and submit it to the store.
Et voilà ! The iOS 4 will handle it automatically to display your new HD images.
30/06/10
How to encrypt/decrypt using AES 256
Here is some code I found in iphonedevelopment.blogspot.com on how to extend NSMutableData to encrypt and decrypt using AES 256 encryption standard, very useful.
#import <CommonCrypto/CommonCryptor.h>
@implementation NSMutableData (AES256)
- (BOOL) encryptWithKey: (NSString *) key {
// 'key' should be 32 bytes for AES256, will be null-padded otherwise
char * keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
bzero( keyPtr, sizeof(keyPtr) ); // fill with zeroes (for padding)
// fetch key data
[key getCString: keyPtr maxLength: sizeof(keyPtr) encoding: NSUTF8StringEncoding];
// encrypts in-place, since this is a mutable data object
size_t numBytesEncrypted = 0;
CCCryptorStatus result = CCCrypt( kCCEncrypt, , kCCAlgorithmAES128, kCCOptionPKCS7Padding,
keyPtr, kCCKeySizeAES256,
NULL /* initialization vector (optional) */,
[self mutableBytes], [self length], /* input */
[self mutableBytes], [self length], /* output */
&numBytesEncrypted );
return ( result == kCCSuccess );
}
- (BOOL) decryptWithKey: (NSString *) key {
// ‘key’ should be 32 bytes for AES256, will be null-padded otherwise
char * keyPtr[kCCKeySizeAES256+1]; // room for terminator (unused)
bzero( keyPtr, sizeof(keyPtr) ); // fill with zeroes (for padding)
// fetch key data
[key getCString: keyPtr maxLength: sizeof(keyPtr) encoding: NSUTF8StringEncoding];
// encrypts in-place, since this is a mutable data object
size_t numBytesEncrypted = 0;
CCCryptorStatus result = CCCrypt( kCCDecrypt, , kCCAlgorithmAES128, kCCOptionPKCS7Padding,
keyPtr, kCCKeySizeAES256,
NULL /* initialization vector (optional) */,
[self mutableBytes], [self length], /* input */
[self mutableBytes], [self length], /* output */
&numBytesEncrypted );
return ( result == kCCSuccess );
}
@end