sudebios

Subtitle

iOS Topics 
       1. json pasring
           * Sample Example .
           * json checking sites 1 2

       2.Core Location and MapView
           * Simple mapview
           * Show pin on mapview
           * Show custom pin color on mapview
           * Add custom pin image on mapview
           * Get location name (Address) from latitude longitude
           * Get latitude longitude from location name (Address)
           * Get restaurants gyms search on a mapview 
           * Display Direction on map.
       3.Sqlite in iOS
       4.Multitusting
       5.File and folder management
       6.Simple Form Design
          a).Validation Check
               * Check Blank Space

-(BOOL)emptyValueChk : (NSString *)str

{


    NSString *rawString =str;

    NSCharacterSet *whitespace = [NSCharacterSet whitespaceAndNewlineCharacterSet];

    NSString *trimmed = [rawString stringByTrimmingCharactersInSet:whitespace];

    NSLog(@" data%@",trimmed) ;

    if ([trimmed length] == 0) 

        return YES ;

    else 

        return NO ;

}



* Numeric Value Check

                                                    -(BOOL)chkNumericNum : (NSString *)str

                                                    {

                                                         NSCharacterSet * set = [[NSCharacterSet characterSetWithCharactersInString:@"0123456789"] invertedSet];

                                                          if ([str rangeOfCharacterFromSet:set].location != NSNotFound) 

                                                          {

                                                         return YES ;

                                                          }

                                                   else

                                                        return NO ;

                                                }




               * Check Email 

- (BOOL) validateEmail: (NSString *) candidate {

    NSString *emailRegex = @"[A-Z0-9a-z._%+-][email protected][A-Za-z0-9.-]+\\.[A-Za-z]{2,6}";

    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];

    return [emailTest evaluateWithObject:candidate];

}


* Touch any place and Hide keyboard

- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event

{

    [phTxt resignFirstResponder];// This will dismiss your keyBoard.

    [emailTxt resignFirstResponder] ;

    [nameTxt resignFirstResponder] ;

    [addressTxt resignFirstResponder];

}


Add Tool Bar to number pad for textField Type
TextField.keyboardType = UIKeyboardTypePhonePad;

-(void)addToolBar

{    UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];

    numberToolbar.barStyle = UIBarStyleBlackTranslucent;

    numberToolbar.items = [NSArray arrayWithObjects:

                           [[UIBarButtonItem alloc]initWithTitle:@"Cancel" style:UIBarButtonItemStyleBordered target:self action:@selector(cancelNumberPad)],

                           [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],

                           [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)],

                           nil];

    [numberToolbar sizeToFit];

    phTxt.inputAccessoryView = numberToolbar;

}


-(void)cancelNumberPad{

    [phTxt resignFirstResponder];

    phTxt.text = @"";

}


-(void)doneWithNumberPad{

    [phTxt resignFirstResponder];

}


*Add Image From Library

-(void)addImageMethod

{

    UIImagePickerController *pickerController = [[UIImagePickerController alloc]

                                                 init];

    pickerController.delegate = self;

    //[self presentModalViewController:pickerController animated:YES];

    [self presentViewController:pickerController animated:YES completion:nil];

}


- (void) imagePickerController:(UIImagePickerController *)picker

         didFinishPickingImage:(UIImage *)image

                   editingInfo:(NSDictionary *)editingInfo

{

    self.sendImage=image ;

    self.imageView.image = image;

    [self dismissModalViewControllerAnimated:YES];

}


* Add View into UItableViewCell 
(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{ static NSString *CellIdentifier = @"CustomTableCell";
    UITableViewCell *cell = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil)
    {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] ;
   }
    UIView *tempVw = [[UIView alloc]initWithFrame:CGRectMake(0, 0, 320, 150)] ;
    [cell.contentView addSubview:tempVw];
    return cell;
}

*Auto Animation Uiview up using textView Delegate Method

- (void)textFieldDidBeginEditing:(UITextField *)textField {    

    [UIView beginAnimations:nil context:NULL];

[UIView setAnimationDelegate:self];

[UIView setAnimationDuration:0.5];

[UIView setAnimationBeginsFromCurrentState:YES];

    if (textField==phTxt) {

        self.view.frame = CGRectMake(0,-100, 320,480);

    }

    if (textField==emailTxt) {

        self.view.frame = CGRectMake(0,-100, 320,480);

    }

[UIView commitAnimations];

}


- (void)textFieldDidEndEditing:(UITextField *)textField {

    [UIView beginAnimations:nil context:NULL];

[UIView setAnimationDelegate:self];

[UIView setAnimationDuration:0.0];

[UIView setAnimationBeginsFromCurrentState:YES];

self.view.frame = CGRectMake(0,0, 320,480);

[UIView commitAnimations];

}


*place Holder Instead of Alert View

    UIColor *color = [UIColor redColor];

 uitextFieldName.attributedPlaceholder = [[NSAttributedString alloc] initWithString:@"* Enter Name " attributes:@{NSForegroundColorAttributeName: color}] ;


*Facebook Login