Create wrapper iOS application from HTML

by alex 12. March 2013 06:31
I wrote small service to create wrapper application froom HTML code http://html5wrapper.com/

Tags:

General

Methods to support orientation in iOS 6 SDK

by alex 31. October 2012 06:37

 

//For UIViewController's

- (BOOL)shouldAutorotate {

    return YES;

}

 

- (NSUInteger)supportedInterfaceOrientations {

    return UIInterfaceOrientationMaskAllButUpsideDown;

}

 

//For Delegate

- (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window {

    return UIInterfaceOrientationMaskAllButUpsideDown;

 

Tags:

General

Handle taps within a UIWebView

by alex 2. January 2012 08:57

//1. Add UIGestureRecognizerDelegate to your interface:

 

@interface DocumentViewControler : UIViewController <UIGestureRecognizerDelegate>

 

//2. Add to viewDidLoad

 

- (void)viewDidLoad {

    [super viewDidLoad];

    

    

    UITapGestureRecognizer* singleTap=[[UITapGestureRecognizer

                                        alloc]initWithTarget:self action:@selector(handleSingleTap:)];

    singleTap.numberOfTouchesRequired=1;

    singleTap.delegate=self;

    [self.webView addGestureRecognizer:singleTap];

    [singleTap release];

}

 

//3. Add:

 

-(BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer

shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer

                                                    *)otherGestureRecognizer {

    return YES;

}

 

//4.

 

-(void) handleSingleTap:(UITapGestureRecognizer *)recognizer  {

    NSLog(@"handleSingleTap");

    

    // Your code here

}

@end

Check if file exists

by alex 4. July 2011 18:46

BOOL fileExists = [[NSFileManager defaultManager] fileExistsAtPath:imagePath];

Show UIActionSheet

by alex 14. March 2011 01:45

 

- (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{

//SMS

if(buttonIndex == 0){


}

//EMAIL

if (buttonIndex == 1){

 

 

}

else

{

}

}

 

-(IBAction)emailAction{

UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"Send by" delegate:self cancelButtonTitle:@"Cancel" destructiveButtonTitle:nil otherButtonTitles:@"SMS", @"Email",nil];

actionSheet.actionSheetStyle = UIActionSheetStyleDefault;

[actionSheet showInView:self.view];

[actionSheet release];

}


UIAlertView without Buttons

by alex 12. March 2011 08:17

//Declare in class following vairiable

UIAlertView *alert;

 

-(void)showAlert{

    alert = [[[UIAlertView alloc] initWithTitle:@"Please Wait..." message:nil delegate:self cancelButtonTitle:nil otherButtonTitles: nil] autorelease];

    

    [alert show];

 

    UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleWhiteLarge];

 

    indicator.center = CGPointMake(alert.bounds.size.width / 2, alert.bounds.size.height - 50);

    [indicator startAnimating];

    [alert addSubview:indicator];

    [indicator release];

}

 

-(void)dismissAlert{

    [alert dismissWithClickedButtonIndex:0 animated:YES];

    [alert release];

}


Get current app version number from bundle

by alex 6. December 2010 00:02

[[[NSBundle mainBundle] infoDictionary] objectForKey:@"CFBundleVersion"]

Check if we are running iOS 4+

by alex 1. December 2010 23:27

+(BOOL)isOS4{

NSComparisonResult order = [[UIDevice currentDevice].systemVersion compare: @"4.0" options: NSNumericSearch];

if (order == NSOrderedSame || order == NSOrderedDescending) {

return YES;

} else {

return NO;

}

}


 

Tags:

General

Convert NSString to NSData

by alex 26. November 2010 02:13

NSString* string= @"Some String";

NSData* data=[string dataUsingEncoding:NSUTF8StringEncoding];

Get Executable File MD5 Signature

by alex 25. November 2010 02:48

#include <CommonCrypto/CommonDigest.h>

 

@implementation YourClass

 

-(NSString*)getExecutableFileMD5Signature{

NSBundle *bundle = [NSBundle mainBundle];

    NSDictionary *info = [bundle infoDictionary];

NSString *execName = [info objectForKey:@"CFBundleExecutable"];

NSData *data = [NSData dataWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.app/%@", NSHomeDirectory(), execName, execName]];

return [self cHash:@"md5" data:data];

}

 

-(NSString*)cHash:(NSString*)algo data:(NSData*)data{

NSData *rdata;

if ([algo isEqualToString:@"sha1"]) {

unsigned char hashBytes[CC_SHA1_DIGEST_LENGTH];

CC_SHA1([data bytes], [data length], hashBytes);

rdata = [NSData dataWithBytes:hashBytes length:CC_SHA1_DIGEST_LENGTH];

}else if ([algo isEqualToString:@"md5" ]) {

unsigned char hashBytes[CC_MD5_DIGEST_LENGTH];

CC_MD5([data bytes], [data length], hashBytes);

rdata = [NSData dataWithBytes:hashBytes length:CC_MD5_DIGEST_LENGTH];

} else {

return @"NULL";

}

return [rdata stringWithHexBytes];

}

 

@end

 

 

//add new method to NSData Class

//convert NSData to HEX NSString

@implementation NSData (NSDataStrings)

 

- (NSString*)stringWithHexBytes {

static const char hexdigits[] = "0123456789abcdef";

const size_t numBytes = [self length];

const unsigned char* bytes = [self bytes];

char *strbuf = (char *)malloc(numBytes * 2 + 1);

char *hex = strbuf;

NSString *hexBytes = nil;

for (int i = 0; i<numBytes; ++i){

const unsigned char c = *bytes++;

*hex++ = hexdigits[(c >> 4) & 0xF];

*hex++ = hexdigits[(c ) & 0xF];

}

*hex = 0;

hexBytes = [NSString stringWithUTF8String:strbuf];

free(strbuf);

return hexBytes;

}

 

@end

Tags:

General

Powered by BlogEngine.NET 1.4.5.0
Theme by Mads Kristensen