my notes

#  webpage mthi remove some texts

NSString *js = @”javascript:document.getElementById(\”mp-menu\”).setAttribute(\”style\”,\”display:none;\”);”;

    [webview stringByEvaluatingJavaScriptFromString:js];

#  set placeholder change color

  NSAttributedString *str = [[NSAttributedString alloc] initWithString:@”EMAIL” attributes:@{ NSForegroundColorAttributeName : [UIColor whiteColor] }];

    email_id.attributedPlaceholder = str;

# set image url

#import “UIImageView+UIActivityIndicatorForSDWebImage.h”

sdimage and uiactivity third part y nd afnetworkig

NSURL *tempurl = [NSURL URLWithString:[app.arr_img objectAtIndex:indexPath.row]];

    [cell.odd_img setImageWithURL:tempurl usingActivityIndicatorStyle:UIActivityIndicatorViewStyleWhite];

# string remove after some word

NSString *str1 =[app.bthview_Arry_Prti valueForKey:@”date”];

    NSRange range = [str1 rangeOfString:@” “];

    

    NSString *newString = [str1 substringToIndex:range.location];

    NSLog(@”%@”,newString);

    

self.tableView.tableFooterView = [[UIView alloc] initWithFrame:CGRectZero];

tbl.contentInset = UIEdgeInsetsMake(-35, 0, 0, 0);

* textview scroll

   [txt_desr scrollRangeToVisible:txt_desr.selectedRange];

    txt_desr.scrollEnabled= NO;

    txt_desr.text = [txt_desr.text stringByAppendingString:str];

    txt_desr.scrollEnabled= YES;

dynamic height

UITextView *txt1=[[UITextView alloc]initWithFrame:CGRectMake(10, (self.view.bounds.size.height/2)+120, self.view.bounds.size.width-20, (self.view.bounds.size.height-40)-((self.view.bounds.size.height/2)+120))];

NSLocationWhenInUseUsageDescription

NSLocationAlwaysUsageDescription

scroll view demo

-(void)scroll_m

{

    int spce=10;

    

    for (int j=1; j<19; j++) {

        NSString *imageName1 = [NSString stringWithFormat:@”bg%d.png”,j ];

        UIImage *image = [UIImage imageNamed:imageName1];

        UIImageView *img_view=[[UIImageView alloc]initWithFrame:CGRectMake(spce, 0, 90, 100)];

       

        [img_view setImage:image];

        img_view.backgroundColor=[UIColor grayColor];

        [scr_view setContentSize:CGSizeMake(scr_view.frame.size.width+spce-210, scr_view.frame.size.height)];

        

        

        [scr_view addSubview:img_view];

        spce=spce+100;

        

    }

        //[scr_view setContentSize:CGSizeMake(scr_view.frame.size.width+200, scr_view.frame.size.height)];

   

}

Rotate view

[UIView transitionWithView:flipContainerView

                      duration:0.75

                       options:UIViewAnimationOptionTransitionFlipFromLeft

                    animations:^{

                        if (flipped)

                                                    {

                                                        img1.hidden=YES;

                                                        img.hidden=NO;

                                                        flipped=false;

                                                    }

                                                    else

                                                    {

                                                        img1.hidden=NO;

                                                        img.hidden=YES;

                                                         flipped=true;

                                                    }

                    }

                    completion:nil];

}

  [[IQKeyboardManager sharedManager] setEnableAutoToolbar:NO];

Alertview with auto timer

UIAlertView *autosaveAlert = [[UIAlertView alloc]initWithTitle:nil message:@”Success Update” delegate:self cancelButtonTitle:nil otherButtonTitles:nil];

        [autosaveAlert show];

        

        for(int i = 10; i>=0; i–){

            NSString *tmp = @”Close in (%d) seconds”;

            NSString *str = [NSString stringWithFormat:tmp, i];

            [autosaveAlert setMessage:str];

            CFRunLoopRunInMode(kCFRunLoopDefaultMode,1, false);

        }

        

        [autosaveAlert dismissWithClickedButtonIndex:0 animated:TRUE];

Get current date and time

(void)getCurrentTime

{

    NSDate *currentDateTime = [NSDate date];

    

    dateFormatter = [[NSDateFormatter alloc] init];

    

    [dateFormatter setDateFormat:@”yyyy-MM-dd”];

    

    

    

    dateInStringFormated = [dateFormatter stringFromDate:currentDateTime];

    

    NSLog(@”%@”, dateInStringFormated);

    

}

NSDate *dateToTExtField=[_datePicker date];

        

    NSDateFormatter *dateFormatter1 = [[NSDateFormatter alloc] init];

    [dateFormatter1 setDateFormat:@”yyyy-MM-dd”];

        

    NSString *strDate = [dateFormatter1 stringFromDate:dateToTExtField];

    NSLog(@”%@”, strDate);

    app.date=strDate;

    }

    else

    {

        NSDateFormatter *dateFormatter2 = [[NSDateFormatter alloc] init];

        [dateFormatter2 setDateFormat:@”yyyy-mm-dd”];

        NSString *strDate = [dateFormatter2 stringFromDate:datePicker.date];

        NSLog(@”%@”, strDate);

        app.date=strDate;

    }

_datePicker.datePickerMode=UIDatePickerModeDate;

    

    [_datePicker setValue:[UIColor orangeColor] forKeyPath:@”textColor”];

    SEL selector = NSSelectorFromString(@”setHighlightsToday:”);

    NSInvocation *invocation = [NSInvocation invocationWithMethodSignature:[UIDatePicker instanceMethodSignatureForSelector:selector]];

    BOOL no = NO;

    [invocation setSelector:selector];

    [invocation setArgument:&no atIndex:2];

    [invocation invokeWithTarget:_datePicker];

    

    [self.view addSubview:_datePicker];

NSUserDefaults * defs = [NSUserDefaults standardUserDefaults];

        [defs removeObjectForKey:@”check”];

        [defs removeObjectForKey:@”medication”];

        [defs removeObjectForKey:@”harvestingmedication”];

        [defs removeObjectForKey:@”transfermedication”];

        

         [[SlideNavigationController sharedInstance] popToRootAndSwitchToViewController:add withSlideOutAnimation:self.slideOutAnimationEnabled andCompletion:nil];

table scroll

-(void)Tbl

{

    if (UI_USER_INTERFACE_IDIOM()==UIUserInterfaceIdiomPhone)

    {

        CGSize device=[[UIScreen mainScreen]bounds].size;

        if (device.height==480)

        {

             _mytable.scrollEnabled=YES;

        }

        else

        {

            _mytable.scrollEnabled=NO;

        }

     }

}

uitap with iamgepicker

UITapGestureRecognizer  *image1 = [[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(imageTaped1)];

    image1.numberOfTapsRequired = 1;

    image1.numberOfTouchesRequired = 1;

    [user_profileimg setUserInteractionEnabled:YES];

    [user_profileimg addGestureRecognizer:image1];

-(IBAction)imageTaped1:(id)sender

{

    UIImagePickerController *picker = [[UIImagePickerController alloc] init];

    picker.delegate = self;

    picker.allowsEditing = YES;

    picker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;

    

    [picker presentViewController:picker animated:YES completion:NULL];

    

}

#pragma mark – Image Picker Controller delegate methods

– (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {

    

    UIImage *chosenImage = info[UIImagePickerControllerEditedImage];

    _image.image = chosenImage;

    

    [picker dismissViewControllerAnimated:YES completion:NULL];

    

}

– (void)imagePickerControllerDidCancel:(UIImagePickerController *)picker

{

    

    [picker dismissViewControllerAnimated:YES completion:NULL];

    

}

image radio make circle

_image.layer.cornerRadius = _image.frame.size.width / 2;

    _image.layer.borderWidth = 1.5f;

    _image.layer.borderColor = [UIColor whiteColor].CGColor;

    _image.clipsToBounds = YES;

-(CGFloat)tableView:(UITableView*)tableView

heightForHeaderInSection:(NSInteger)section {

    if (section == 0)

    {

        return 6.0;

    }

    

    return 1.0;

}

– (CGFloat)tableView:(UITableView*)tableView

heightForFooterInSection:(NSInteger)section {

    return 15.0;

}

– (UIView*)tableView:(UITableView*)tableView

viewForHeaderInSection:(NSInteger)section {

    return [[UIView alloc] initWithFrame:CGRectZero];

}

– (UIView*)tableView:(UITableView*)tableView

viewForFooterInSection:(NSInteger)section {

    return [[UIView alloc] initWithFrame:CGRectZero];

}

time  or date difference

NSString *strb4=text2.text;

    NSString *strcd=text3.text;

    

    

    NSDateFormatter* df = [[NSDateFormatter alloc] init];

    [df setDateFormat:@”yyyy-MM-dd”];

    NSDate* date1 = [df dateFromString:strb4];

    

    NSDate *date2 = [df dateFromString:strcd];

    

//    NSDate *b4date = [dateFormatter dateFromString:strb4];

//    NSDate *cdate=[dateFormatter dateFromString:strcd];

//    

    NSTimeInterval t123=[date2 timeIntervalSinceDate:date1];

    NSLog(@”%f”,t123);

https://maps.googleapis.com/maps/api/staticmap?scale=1&size=400×400&zoom=16&center= 51.5109632,0.13024429999995846&style=feature:all|element:labels.text.fill|saturation:36|color:0x999999|lightness:40&style=feature:all|element:labels.text.stroke|visibility:on|color:0x2B2B2B|lightness:16&style=feature:all|element:labels.icon|visibility:oncolor:0xB6B6B4|lightness:36&style=feature:administrative|element:geometry.fill|color:0x5C5858&style=feature:administrative|element:geometry.stroke|color:0x2B2B2B|lightness:20|weight:1.2&style=feature:landscape|element:geometry|color:0x5C5858|lightness:20&style=feature:poi|element:geometry|color:0x3D3C3A|lightness:21&style=feature:road.highway|element:geometry.fill|color:0x000000|lightness:17&style=feature:road.highway|element:geometry.stroke|color:0x5C5858|lightness:29|weight:0.2&style=feature:road.arterial|element:geometry|color:0x2B2B2B|lightness:18&style=feature:road.local|element:geometry|color:0x2B2B2B|lightness:16&style=feature:transit|element:geometry|color:0x5C5858|lightness:19&style=feature:water|element:geometry|color:0x636363|lightness:17&markers=color:blue|label:C| 51.5109632,0.13024429999995846

UILocalNotification *localNotification = [[UILocalNotification alloc]init];

   // Set the notification time.

    localNotification.fireDate = [NSDate dateWithTimeIntervalSinceNow:10];

   // You can specify the alarm sound here.

   localNotification.soundName = UILocalNotificationDefaultSoundName;

   //OR

   localNotification.soundName = @”sound.caf”;

   // Set the alertbody of the notification here.

    localNotification.alertBody = @”Test Alert”;

   // Create the buttons on the notification alertview.

    localNotification.alertAction = @”View”;

   // You can also specify custom dictionary to store informations

    NSDictionary *infoDict = [NSDictionary dictionaryWithObject:@”alarm#2″ forKey:@”notifiKey”];

    localNotification.userInfo = infoDict;

    //Repeat the notification.

    localNotification.repeatInterval = NSDayCalendarUnit;

// Schedule the notification

[[UIApplication sharedApplication]scheduleLocalNotification:localNotification];

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s