1. "Handle taps within a UIWebView"

    Mon 02 January 2012

    //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 ...

    read more
  2. "Show UIActionSheet"

    Mon 14 March 2011

     

    - (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];

    }


    read more
  3. "UIAlertView without Buttons"

    Sat 12 March 2011

    //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 ...

    read more
  4. "Send SMS"

    Fri 11 March 2011

    - (void)messageComposeViewController:(MFMessageComposeViewController *)controller didFinishWithResult:(MessageComposeResult)result{

    switch (result) {

    case MessageComposeResultCancelled:

    NSLog(@"Cancelled");

    break;

    case MessageComposeResultFailed:{

    UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Application" message:@"Unknown Error"

      delegate:nil cancelButtonTitle:@"OK" otherButtonTitles: nil];

    [alert show];

    [alert release];

    break;}

    case MessageComposeResultSent:

    break;

    default:

    break;

    }

    [self dismissModalViewControllerAnimated:YES];

    }

     

    - (void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger ...

    read more
  5. "Get current app version number from AndroidManifest.xml"

    Sun 20 February 2011

      //Usage from activity:

      //String verison = GlobalSettings.getVersionName(this,MyActivity.class)

      public static String getVersionName(Context context, Class cls) {

        try {

          ComponentName comp = new ComponentName(context, cls);

          PackageInfo pinfo = context.getPackageManager().getPackageInfo(comp.getPackageName(), 0);

          return "Version: " + pinfo.versionName;

        } catch (android.content.pm.PackageManager.NameNotFoundException e) {

          return null;

        }

      }


    read more
  6. "Check if we are running iOS 4+"

    Wed 01 December 2010

    +(BOOL)isOS4{

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

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

    return YES;

    } else {

    return NO;

    }

    }


     

    read more
  7. "Buttons in navigation bar"

    Sun 28 November 2010

     

    - (id)initWithStyle:(UITableViewStyle)style {

        // Override initWithStyle: if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.

        if (self = [super initWithStyle:style]) {

    UIBarButtonItem *doneBarButtonItem = [[UIBarButtonItem alloc] //init];

    initWithTitle:@"Done"

    style:UIBarButtonItemStyleBordered

    target:self 

    action:@selector(doneAction:)];

    self.navigationItem.leftBarButtonItem = doneBarButtonItem;

    [doneBarButtonItem release];

        }

        return self ...

    read more

« Page 2 / 13 »