Friday, May 15, 2015

two things you need to do when using corelocation on 8.0+

firstly.
add NSLocationWhenInUseUsageDescription to info.plst.


secondly.
use this code to get authorization

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0){
        [self.locationManager requestWhenInUseAuthorization];

    }

Wednesday, May 13, 2015

make tableview cell unselectable

- (NSIndexPath *)tableView:(UITableView *)tv willSelectRowAtIndexPath:(NSIndexPath *)path
{
   // NSLog(@"here");
    return nil;

}

Saturday, May 02, 2015

IOS email validation



-(BOOL) NSStringIsValidEmail:(NSString *)checkString
{
   BOOL stricterFilter = NO; // Discussion http://blog.logichigh.com/2010/09/02/validating-an-e-mail-address/
   NSString *stricterFilterString = @"[A-Z0-9a-z\\._%+-]+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2,4}";
   NSString *laxString = @".+@([A-Za-z0-9-]+\\.)+[A-Za-z]{2}[A-Za-z]*";
   NSString *emailRegex = stricterFilter ? stricterFilterString : laxString;
   NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
   return [emailTest evaluateWithObject:checkString];
}

IOS programatically jump to another view

1st, create a segue between your current view and the view you want to jump to. e.g, ViewMe and ViewLogin. Set the set identity of the segue to like 'Me2LoginSegue'.

2nd,  Ctrl+drag the button to the .h file,  create an action name like 'onClickLoginSubmit'.

3rd, put this code into the method you created in the .m file.  like this
- (IBAction)onClickLoginSubmit:(id)sender {
    [self performSegueWithIdentifier: @"Me2LoginSegue" sender: self];
}

@end

Done

Friday, May 01, 2015

programatic set uitableview row height

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    
    if([Utils IsUserLoggedIn] && indexPath.section == 0 && indexPath.row == 0)
    {
        
        self.LoginView.frame = CGRectMake(0, 0, self.LoginView.frame.size.width, 800);
        self.LoginButton.frame = CGRectMake(self.LoginButton.frame.origin.x, self.LoginButton.frame.origin.x, self.LoginView.frame.size.width, 34);
        return 800;
    }
    else{
        return UITableViewAutomaticDimension;
    }

}