Archivi categoria: Sviluppo iPad/iPhone

iPhone Dev – Asynchronous image downloader with cache support with an UIImageView category

Here git of Asynchronous image downloader with cache support with an UIImageView category. This library provides a category for UIImageVIew with support for remote images coming from the web.

It provides:

  • An UIImageView category adding web image and cache management to the Cocoa Touch framework
  • An asynchronous image downloader
  • An asynchronous memory + disk image caching with automatic cache expiration handling
  • Animated GIF support
  • WebP format support
  • A background image decompression
  • A guarantee that the same URL won’t be downloaded several times
  • A guarantee that bogus URLs won’t be retried again and again
  • A guarantee that main thread will never be blocked
  • Performances!
  • Use GCD and ARC

https://github.com/rs/SDWebImage

IOS iPhone/iPad – check call service capability of the device

sometimes you need to check the type of device that will use our application in order to identify whether the device is an iphone, ipod or iPad. To check this we can read the [UIDevice currentDevice].model such you are essentially comparing the device name with a hard-coded value. Example

if(![[UIDevice currentDevice].model isEqualToString:@"iPhone"])
{
UIAlertView *alertView = [UIAlertView alloc] initWithTitle:@"Error"
message:@"Call service not avalible on this device"
delegate:self
cancelButtonTitle:@"close"
otherButtonTitles: nil];
[alertView show];
[alertView release];
}

as alternative we can add a control if the device can openURL “tel:xxx-xxxx-xxxx” which is the protocol used to make a call on an iPhone device:

[[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:RISTOSTREGA_PHONE]]

more in deep we ca use to know exactly the generation of device the class UIDeviceHardware:

UIDeviceHardware *h=[[UIDeviceHardware alloc] init];
[self setDeviceModel:[h platformString]];
[h release];

the class UIDeviceHardware.h:

@interface UIDeviceHardware : NSObject
- (NSString *) platform;
- (NSString *) platformString;
@end

in the implementation file UIDeviceHardware.m:

#include
#include

@implementation UIDeviceHardware

- (NSString *) platform{
size_t size;
sysctlbyname("hw.machine", NULL, &size, NULL, 0);
char *machine = malloc(size);
sysctlbyname("hw.machine", machine, &size, NULL, 0);
NSString *platform = [NSString stringWithCString:machine];
free(machine);
return platform;
}

- (NSString *) platformString{
NSString *platform = [self platform];
if ([platform isEqualToString:@"iPhone1,1"]) return @"iPhone 1G";
if ([platform isEqualToString:@"iPhone1,2"]) return @"iPhone 3G";
if ([platform isEqualToString:@"iPhone2,1"]) return @"iPhone 3GS";
if ([platform isEqualToString:@"iPod1,1"]) return @"iPod Touch 1G";
if ([platform isEqualToString:@"iPod2,1"]) return @"iPod Touch 2G";
if ([platform isEqualToString:@"iPod3,1"]) return @"iPod Touch 4G";
if ([platform isEqualToString:@"i386"]) return @"iPhone Simulator";
return platform;
}

@end

Integrate the three20 library into your iOS project in 3 steps without error Can’t find #import “Three20/Three20.h”

Download three20 library with this command git clone git://github.com/facebook/three20.git

1) Copy the three20 folder into your iphone project: goto in [YourProjectsFolders]/[iOSProjectName] and copy three20 folder here
2) from console locate the three20 folder and run this python command
python src/scripts/ttmodule.py -p ../[iOSProjectName].xcodeproj Three20 -c Debug -c Release
3) now go to XCode and build. If yet opened reload project.

iPad / Iphone – Hide Statusbar

To hide the application statusbar we can choose 2 way:

add this key  and set it boolean value to “true” inside the application info.plist

<key>UIStatusBarHidden</key>

<true />


or using the application singletone class programmatically,
in this way:


[[UIApplication sharedApplication] setStatusBarHidden:YES animated:NO];

this is all