Friday 27 September 2013

UITableView - Scroll Table Hader As Row Scroll

Here is code to scroll table header as table row scroll up.

- (void)scrollViewDidScroll:(UIScrollView *)scrollView {
    CGFloat sectionHeaderHeight = 40;//Change as per your table header hight
    if (scrollView.contentOffset.y<=sectionHeaderHeight&&scrollView.contentOffset.y>=0) {
        scrollView.contentInset = UIEdgeInsetsMake(-scrollView.contentOffset.y, 0, 0, 0);
    } else if (scrollView.contentOffset.y>=sectionHeaderHeight) {
        scrollView.contentInset = UIEdgeInsetsMake(-sectionHeaderHeight, 0, 0, 0);
    }
}

Wednesday 17 July 2013

Resize UImage

UIImage can be re sized or scaled to fit in frame or to reduce size to send over network. Below is the utility function that takes UIImage and target dimensions (in terms of CGSize), and returns resized UIImage.

---------------------------------------------------------------------------
Example - 1
UIImage *small = [UIImage imageWithCGImage:original.CGImage scale:0.25 orientation:original.imageOrientation];
---------------------------------------------------------------------------
Example - 2
UIGraphicsBeginImageContext(CGSizeMake(100,100));
 [imgView.image drawInRect:CGRectMake(0, 0,100,100)];
 UIImage* scaledImage = UIGraphicsGetImageFromCurrentImageContext();
 imgView.image = scaledImage;
 UIGraphicsEndImageContext();
---------------------------------------------------------------------------
Include QuartzCore.FrameWork in project
Import <QuartzCore/QuartzCore.h> in implementation file

Example - 3
- (UIImage *)resizeImageToSize:(CGSize)targetSize
{
    UIImage *sourceImage = self.imageToFitInBackground;
    UIImage *newImage = nil;

    CGSize imageSize = sourceImage.size;
    CGFloat width = imageSize.width;
    CGFloat height = imageSize.height;
    CGFloat targetWidth = targetSize.width;
    CGFloat targetHeight = targetSize.height;
    CGFloat scaleFactor = 0.0;
    CGFloat scaledWidth = targetWidth;
    CGFloat scaledHeight = targetHeight;
    CGPoint thumbnailPoint = CGPointMake(0.0,0.0);

    if (CGSizeEqualToSize(imageSize, targetSize) == NO) {
        CGFloat widthFactor = targetWidth / width;
        CGFloat heightFactor = targetHeight / height;
        if (widthFactor < heightFactor)
            scaleFactor = widthFactor;
        else
            scaleFactor = heightFactor;
        scaledWidth  = width * scaleFactor;
        scaledHeight = height * scaleFactor;
        // make image center aligned
        if (widthFactor < heightFactor)
        {
           thumbnailPoint.y = (targetHeight - scaledHeight) * 0.5;
        }
        else if (widthFactor > heightFactor)
        {
            thumbnailPoint.x = (targetWidth - scaledWidth) * 0.5;
        }
    }
    UIGraphicsBeginImageContext(targetSize);
    CGRect thumbnailRect = CGRectZero;
    thumbnailRect.origin = thumbnailPoint;
    thumbnailRect.size.width  = scaledWidth;
    thumbnailRect.size.height = scaledHeight;
    [sourceImage drawInRect:thumbnailRect];
    newImage = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
    if(newImage == nil)
       NSLog(@"could not scale image");
    return newImage ;
}

 ---------------------------------------------------------------------------
Example - 4

- (UIImage *)scaleAndRotateImage:(UIImage *)image
{
    static int kMaxResolution = 300;
   
    CGImageRef imgRef = image.CGImage;
    CGFloat widtha = CGImageGetWidth(imgRef);
    CGFloat heighta = CGImageGetHeight(imgRef);
   
    CGAffineTransform transform = CGAffineTransformIdentity;
    CGRect bounds = CGRectMake(0, 0, widtha, heighta);
    if (widtha > kMaxResolution || heighta > kMaxResolution) {
        CGFloat ratio = widtha/heighta;
        if (ratio > 1) {
            bounds.size.width = kMaxResolution;
            bounds.size.height = bounds.size.width / ratio;
        } else {
            bounds.size.height = kMaxResolution;
            bounds.size.width = bounds.size.height * ratio;
        }
    }
   
    CGFloat scaleRatio = bounds.size.width / widtha;
    CGSize imageSize = CGSizeMake(CGImageGetWidth(imgRef), CGImageGetHeight(imgRef));
    CGFloat boundHeight;
   
    UIImageOrientation orient = image.imageOrientation;
    switch(orient) {
        case UIImageOrientationUp:
            transform = CGAffineTransformIdentity;
            break;
        case UIImageOrientationUpMirrored:
            transform = CGAffineTransformMakeTranslation(imageSize.width, 0.0);
            transform = CGAffineTransformScale(transform, -1.0, 1.0);
            break;
        case UIImageOrientationDown:
            transform = CGAffineTransformMakeTranslation(imageSize.width, imageSize.height);
            transform = CGAffineTransformRotate(transform, M_PI);
            break;
        case UIImageOrientationDownMirrored:
            transform = CGAffineTransformMakeTranslation(0.0, imageSize.height);
            transform = CGAffineTransformScale(transform, 1.0, -1.0);
            break;
        case UIImageOrientationLeftMirrored:
            boundHeight = bounds.size.height;
            bounds.size.height = bounds.size.width;
            bounds.size.width = boundHeight;
            transform = CGAffineTransformMakeTranslation(imageSize.height, imageSize.width);
            transform = CGAffineTransformScale(transform, -1.0, 1.0);
            transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
            break;
        case UIImageOrientationLeft:
            boundHeight = bounds.size.height;
            bounds.size.height = bounds.size.width;
            bounds.size.width = boundHeight;
            transform = CGAffineTransformMakeTranslation(0.0, imageSize.width);
            transform = CGAffineTransformRotate(transform, 3.0 * M_PI / 2.0);
            break;
        case UIImageOrientationRightMirrored:
            boundHeight = bounds.size.height;
            bounds.size.height = bounds.size.width;
            bounds.size.width = boundHeight;
            transform = CGAffineTransformMakeScale(-1.0, 1.0);
            transform = CGAffineTransformRotate(transform, M_PI / 2.0);
            break;
        case UIImageOrientationRight:
            boundHeight = bounds.size.height;
            bounds.size.height = bounds.size.width;
            bounds.size.width = boundHeight;
            transform = CGAffineTransformMakeTranslation(imageSize.height, 0.0);
            transform = CGAffineTransformRotate(transform, M_PI / 2.0);
            break;
        default:
            [NSException raise:NSInternalInconsistencyException format:@"Invalid image orientation"];
    }
   
    UIGraphicsBeginImageContext(bounds.size);
    CGContextRef context = UIGraphicsGetCurrentContext();
    if (orient == UIImageOrientationRight || orient == UIImageOrientationLeft) {
        CGContextScaleCTM(context, -scaleRatio, scaleRatio);
        CGContextTranslateCTM(context, -heighta, 0);
    } else {
        CGContextScaleCTM(context, scaleRatio, -scaleRatio);
        CGContextTranslateCTM(context, 0, -heighta);
    }
    CGContextConcatCTM(context, transform);
    CGContextDrawImage(UIGraphicsGetCurrentContext(), CGRectMake(0, 0, widtha, heighta), imgRef);
    UIImage *imageCopy = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();
   
   
    UIGraphicsBeginImageContext(CGSizeMake(250.0f,250.0f));
    [imageCopy drawInRect:CGRectMake(0, 0, 250, 250)];
    UIImage *newImage = UIGraphicsGetImageFromCurrentImageContext();   
    UIGraphicsEndImageContext();
    // return newImage;
   
   
    return newImage;
}




UIImage Utility 
UIImage 

Thursday 11 July 2013

Attch UIToolbar with UITextfield key-board.

As of iOS 3.2 there's a new way to achieve this effect:
UITextFields and UITextViews have an inputAccessoryView property, which you can set to any view, that is automatically displayed above and animated with the keyboard.
Note that the view you use should neither be in the view hierarchy elsewhere, nor should you add it to some superview, this is done for you.
------------------------------------------------------------------------
Code Example:

UIToolbar* numberToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
    numberToolbar.barStyle = UIBarStyleBlack;
    numberToolbar.items = [NSArray arrayWithObjects:
                           [[UIBarButtonItem alloc]initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil],
                           [[UIBarButtonItem alloc]initWithTitle:@"Done" style:UIBarButtonItemStyleDone target:self action:@selector(doneWithNumberPad)],
                           nil];
    [numberToolbar sizeToFit];
    textField.inputAccessoryView = numberToolbar; //textfield is reference for your text box.

-(void)doneWithNumberPad
{
    [textField resignFirstResponder];
}









More Detail

Tuesday 9 July 2013

Reload UITableView particular row with animation.

To animate a batch insertion and deletion of rows and sections, call the insertion and deletion methods within an animation block defined by successive calls to beginUpdates and endUpdates. If you don’t call the insertion and deletion methods within this block, row and section indexes may be invalid. beginUpdates...endUpdates blocks are not nestable.
At the conclusion of a block—that is, after endUpdates returns—the table view queries its data source and delegate as usual for row and section data. Thus the collection objects backing the table view should be updated to reflect the new or removed rows or sections.
The reloadSections:withRowAnimation: and reloadRowsAtIndexPaths:withRowAnimation: methods, which were introduced in iPhone OS 3.0, are related to the methods discussed above. They allow you to request the table view to reload the data for specific sections and rows instead of loading the entire visible table view by calling reloadData.

 Example Code:

------------------------------------------------------------------------


 NSIndexPath *myIP = [NSIndexPath indexPathForRow:0 inSection:0];//Indexpath for row which want to reload
   
    [tableView canCancelContentTouches];
    [tableView beginUpdates];
    [tableView reloadRowsAtIndexPaths:[NSArray arrayWithObject:myIP]
                 withRowAnimation:UITableViewRowAnimationRight];//You can change animation option.
    [tableView endUpdates];

Wednesday 26 June 2013

iOs question

1. What are the Application states. Explain them?
Answer : 
Not running State:  The app has not been launched or was running but was terminated by the  system.if its background and crash.
Inactive state: The app is running in the foreground but is currently not receiving events. (It may be executing other code though.) An app usually stays in this state only briefly as it transitions to a different state. The only time it stays inactive for any period of time is when the user locks the screen or the system prompts the user to respond to some event, such as an incoming phone call or SMS message. Generally  call VoIP support application.
Active state: The app is running in the foreground and is receiving events. This is the normal mode for foreground apps.User work on its.
Background state:  The app is in the background and executing code. Most apps enter this state briefly on their way to being suspended. However, an app that requests extra execution time may remain in this state for a period of time. In addition, an app being launched directly into the background enters this state instead of the inactive state. For information about how to execute code while in the background, see “Background Execution and Multitasking.” Most of location based application.
Suspended state:The app is in the background but is not executing code. The system moves apps to this state automatically and does not notify them before doing so. While suspended, an app remains in memory but does not execute any code. When a low-memory condition occurs, the system may purge suspended apps without notice to make more space for the foreground app.like its receive push notification.
More
-----------------------------------------------------------------------------------------------------------

2. Difference between shallow copy and deep copy?
Answer :
Shallow copy is also known as address copy. In this process you only copy address not actual data while in deep copy you copy data.

-----------------------------------------------------------------------------------------------------------


3. Whats the difference between frame and bounds?
Answer :
The frame of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to the superview it is contained within. The bounds of a view is the rectangle, expressed as a location (x,y) and size (width,height) relative to its own coordinate system (0,0).
What is difference between NSNotification and delegate?
Delegate is passing message from one object to other object. It is like one to one communication while nsnotification is like passing message to multiple objects at the same time. All other objects that have subscribed to that notification or acting observers to that notification can or can’t respond to that event. Notifications are easier but you can get into trouble by using those like bad architecture. Delegates are more frequently used and are used with help of protocols.
56.What are KVO and KVC?
KVC: Normally instance variables are accessed through properties or accessors but KVC gives another way to access variables in form of strings. In this way your class acts like a dictionary and your property name for example “age” becomes key and value that property holds becomes value for that key. For example, you have employee class with name property.
KVO : The mechanism through which objects are notified when there is change in any of property is called KVO.


hope this will useful to you. If any new question please share with us....Thank you...:)

Statusbar - How to hide/show status bar in i Os

The status bar can be gradient gray (with black text), black opaque (with white text), or black translucent. By default the status bar is gray. If your app features standard iPhone UI elements, then stick with the default status bar. However if your app has custom views with dark backgrounds, then a black status bar will look better.
Black and white status bars push the underlying views down, giving you 320 x 460 pixels of screen space to work with in your app. A translucent status bar overlays the underlying view, giving you the full 320 x 480 pixels of screen space.
You can set the status bar style either programmatically or in your Info.plist file. If you change it in Info.plist, then the style is changed when the app launches (while the app is loading). If you change it programmatically, then the style changes after the app finishes loading.


//To hide
    [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationFade];


//To Show
    [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];


Hope this i useful to your coding. If and new important on status bar then please share with us …. thank you…:)

Friday 21 June 2013

UIImage - Make Image Blur

In iOs 7 there is grate use of blur image. Its look awesome .. Here is function to make any image blur. In that original image is blur start with 0.0 and increase it unto 1.0 as requirement.

Example :

- (UIImage *)blurryImage:(UIImage *)image withBlurLevel:(CGFloat)blur {
    if ((blur < 0.0f) || (blur > 1.0f)) {
        blur = 0.5f;
    }
   
    int boxSize1 = (int)(blur * 100);
    boxSize1 -= (boxSize1 % 2) + 1;
   
    CGImageRef img = image.CGImage;
   
    vImage_Buffer inBuffer, outBuffer;
    vImage_Error error;
    void *pixelBuffer;
   
    CGDataProviderRef inProvider = CGImageGetDataProvider(img);
    CFDataRef inBitmapData = CGDataProviderCopyData(inProvider);
   
    inBuffer.width = CGImageGetWidth(img);
    inBuffer.height = CGImageGetHeight(img);
    inBuffer.rowBytes = CGImageGetBytesPerRow(img);
   
    inBuffer.data = (void*)CFDataGetBytePtr(inBitmapData);
   
    pixelBuffer = malloc(CGImageGetBytesPerRow(img) * CGImageGetHeight(img));
       
    outBuffer.data = pixelBuffer;
    outBuffer.width = CGImageGetWidth(img);
    outBuffer.height = CGImageGetHeight(img);
    outBuffer.rowBytes = CGImageGetBytesPerRow(img);
   
    error = vImageBoxConvolve_ARGB8888(&inBuffer, &outBuffer, NULL,
                                       0, 0, boxSize1, boxSize1, NULL,
                                       kvImageEdgeExtend);
   
   
    if (error) {
        NSLog(@"error from convolution %ld", error);
    }
   
    CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
    CGContextRef ctx = CGBitmapContextCreate(
                                             outBuffer.data,
                                             outBuffer.width,
                                             outBuffer.height,
                                             8,
                                             outBuffer.rowBytes,
                                             colorSpace,
                                             CGImageGetBitmapInfo(image.CGImage));
   
    CGImageRef imageRef = CGBitmapContextCreateImage (ctx);
    UIImage *returnImage = [UIImage imageWithCGImage:imageRef];
   
    //clean up
    CGContextRelease(ctx);
    CGColorSpaceRelease(colorSpace);
   
    free(pixelBuffer);
    CFRelease(inBitmapData);
   
    CGColorSpaceRelease(colorSpace);
    CGImageRelease(imageRef);
   
    return returnImage;
}



Hope this will useful in your code…. if any useful code for same please share it with us…..Thank You…:)

Wednesday 19 June 2013

Animation Example


Simple Animation

Here (In example 1) is simple animation code. That is straight forward and easy please read its step by step comment.
Example 1
---------------------------------------------------------------------------------
[UIView beginAnimations:nil context:nil];    //Animation Start
[UIView setAnimationDuration:0.70];    //How long animation is run.
[UIView setAnimationDelay:0.0];    //Is there any wait to perform animation.
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];    //Animation Type
//Your Code For Animating Element.
[UIView commitAnimations];    //End Animation
---------------------------------------------------------------------------------

Simple Animation Block

In example 2 its display simple animation block. That take only animation time and other element work as default for customize those element please refers other example.
Example 2
---------------------------------------------------------------------------------
[UIView animateWithDuration:1.0f animations:^{ //Your Code For Animating Element.
}];
---------------------------------------------------------------------------------
Animation With Completion Block
This(In example 3) is simple animation block that use when condition like wait until animation is done. In below example we create one animation block in that first line we its duration as 1 then start animation that mean animation is completed in 1 minute you can edit that as per your requirement. Then in second block , its call completion that mean that block execution when animation is completed in below case that call after 1 min.

Example : 3
---------------------------------------------------------------------------------
[UIView animateWithDuration:1.0
                 animations:^{
                     //Your Code For Animating Element.
                 }
                 completion:^(BOOL finished){
                     //Wait until above animation is done.
                 }];
---------------------------------------------------------------------------------

Animation With Completion Block and Other Parameter.
Example : 4
---------------------------------------------------------------------------------
[UIView animateWithDuration:0.5
                      delay:0
                    options:UIViewAnimationOptionBeginFromCurrentState
                 animations:^{
                     //Your Code For Animating Element.
                 }
                 completion:^(BOOL finished){
                    
                 }];
---------------------------------------------------------------------------------

Example : 5
---------------------------------------------------------------------------------
[UIView animateWithDuration:0.5
                      delay:0
                    options:UIViewAnimationOptionBeginFromCurrentState
                 animations:^{
                     //Your Code For Animating Element.
                 }
                 completion:^(BOOL finished){
                     //Second Animation Block.
                     [UIView animateWithDuration:0.5
                                           delay:0
                                         options:UIViewAnimationOptionBeginFromCurrentState
                                      animations:^{
                                      completion:nil];
                                      }];
---------------------------------------------------------------------------------
                    
   What Can Be Animated ?                 
                
Here is Some sample animation code that may useful to you.
Flip button with two image.
                    
 //First Click
     [button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateHighlighted];
     [button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateNormal];
     [button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateSelected];
                    
     [UIView beginAnimations:nil context:nil];
     [UIView setAnimationDuration:0.75];
     [UIView setAnimationDelegate:self];
     [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:btnListCal cache:YES];
                    
     [button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateHighlighted];
     [button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateNormal];
     [button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateSelected];
     [UIView commitAnimations];
                    
 //Second Click
    [button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateHighlighted];
    [button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateNormal];
    [button setImage:[UIImage imageNamed:@"calandarimage.png"] forState:UIControlStateSelected];
                    
    [UIView beginAnimations:nil context:nil];
    [UIView setAnimationDuration:0.75];
    [UIView setAnimationDelegate:self];
    [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:btnListCal cache:YES];
                    
     [button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateHighlighted];
     [button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateNormal];
     [button setImage:[UIImage imageNamed:@"listimage.png"] forState:UIControlStateSelected];       
     [UIView commitAnimations];
                    
Explanation :
      button is UIButton reference. The best example for fill button is in iPod Music application in iPhone.
                        
                        
 Hope this will useful to you please share your trick and tip for UIAnimation. Thank You….:)

Tuesday 18 June 2013

get address using reverseGeocodeLocation

A geocoder object uses a network service to convert between latitude and longitude values and a user-friendly placemark, which is a collection of data such as the street, city, state, and country information. Reverse geocoding is the process of converting a latitude and longitude into a placemark. Forward geocoding is the process of converting place name information into a latitude and longitude value. Reverse geocoding is supported in all versions of iOS but forward geocoding is supported only in iOS 5.0 and later.


Function That get currunt address
-------------------------------------------------------------
-(void)getAddressFromCurruntLocation:(CLLocation *)location{
   
    CLGeocoder *geocoder = [[CLGeocoder alloc] init];
    [geocoder reverseGeocodeLocation:location completionHandler:^(NSArray *placemarks, NSError *error)
     {
         if(placemarks && placemarks.count > 0)
         {
             CLPlacemark *placemark= [placemarks objectAtIndex:0];
             //address is NSString variable that declare in .h file.
             address = [[NSString stringWithFormat:@"%@ , %@ , %@",[placemark thoroughfare],[placemark locality],[placemark administrativeArea]] retain];
             NSLog(@"New Address Is:%@",address);
         }
     }];
}
-------------------------------------------------------------

Additional References


Hope this will useful for getting current address. If any suggestion or improvement then please share it. Thank You....:)



NSURLConnection Asynchronous Request

An NSURLConnection object provides support to perform the loading of a URL request. The interface for NSURLConnection is sparse, providing only the controls to start and cancel asynchronous loads of a URL request.
NSURLConnection’s delegate methods—defined by the NSURLConnectionDelegate Protocol protocol—allow an object to receive informational callbacks about the asynchronous load of a URL request. Other delegate methods provide facilities that allow the delegate to customize the process of performing an asynchronous URL load. These delegate methods are called on the thread that started the asynchronous load operation for the associated NSURLConnection object.
NSURLConnection has a convenience class method, sendSynchronousRequest:returningResponse:error:, to load a URL request synchronously.

Example Code





-----------------------------------------------------------------
NSString *strURL= [NSString stringWithFormat:@"http://www.google.com/"];//Here is pass your json link
NSURL *URL = [NSURL URLWithString:[strURL stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    NSURLRequest *requestURL = [[NSURLRequest alloc] initWithURL:URL];
    [NSURLConnection sendAsynchronousRequest:requestURL
                                       queue:[NSOperationQueue mainQueue]
                           completionHandler:^(NSURLResponse *response, NSData *data, NSError *error)
     {
         //When Json request complite then call this block
         NSLog(@"Json Call Done Perform Your Action with data");
         NSLog(@"Reply is:%@",[[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]);
     }];
-----------------------------------------------------------------

Additional References



Here is example to use NSURLConnection with asynchronouse. You can use this to call your request while other process is running. Any other useful way to use this code or any correction then please share it. Thank you...:)

Monday 17 June 2013

iOs 7 New Feature

iOs 7 New Feature.

Control Center : Give you quick access for your device setting like Airplane mode, turn Wi-Fi on or off, or adjust the brightness of your display etc. Good feature.
Notification Center : New feature called Today,Missed gives you a convenient summary of, today notification and missed notification .
Multitasking : Multitasking has always been a smart way to switch between apps.
Camera : Camera in iOS 7 puts all your shooting formats — still, video, panorama, and now square — front and center.Very Good feature.
Photos : Change its display format.
AirDrop : Good feature to share our data.
Safari : change looks and some feature.Mostly design is previously we are used.
iTunes Radio : streaming radio stations.
Siri : gets new look ,more natural-sounding
App Store : shows you a collection of popular apps relevant to your current location , new Kids category spotlights the best apps for children based on age.
Find My iPhone : new security features in iOS 7 make it harder for anyone who’s not you to use or sell your device.


Above feature is announced by apple that may improve our development. Other lot may feature that all effect our development but that may know after its launch in market its may change customer requirement and design view. If any new feature that you know apart from this then please share with us.


Other feature that mention in key note

  • Enterprise single sign-on
  • View PDF annotations
  • Inclinometer
  • Long MMS support
  • Per app VPN
  • Maps bookmark syncing
  • Phone, FaceTime and Message blocking
  • Smart download of TV episodes
  • Notification sync
  • Night mode for Maps
  • WiFi HotSpot 2.0
  • Scan to acquire Passbook passes
  • Turn-by-turn walking directions
  • FaceTime audio
  • New smart Mailboxes
  • Managed app configuration
  • App Store Volume Purchase
  • Tencent Weibo
  • Chinese English bilingual dictionary
  • Handwriting recognition for multiple Chinese characters
  • Improved Mail search
  • Streamline MDM enrollment
  • Do Not Track option in Safari
  • Italian, Korean and Dutch dictionaries





Additional Framework Enhancements
With the advent of iOS 7, many frameworks have got significant enhancements, which allow developers to add distinctive functionality to their apps. Below is the list of enhanced APIs:
UIKit Framework
Store Kit Framework
Security Framework
Pass Kit Framework
OpenGL ES
MessageUI Framework
Media Player Framework
Map Kit Framework
Image I/O Framework
iAd Framework
Game Kit Framework
Foundation Framework
Core Telephony Framework
Core Motion Framework
Core Location Framework
Core Foundation Framework
Core Bluetooth Framework
AV Foundation Framework
Accelerate Framework

See more


NSNotificationCenter


Here is note for NSNotificationCenter if you have any new tip on NSNotificationCenter then please write in comment so i'll add in note so it'll useful for other.If you have any tip to use NSNotificationCenter then also share we me.Here is simple way to implement Notifications.

Notifications are an incredibly useful way to send messages (and data) between objects that otherwise don't know about each other. Think of it like a radio station broadcasting messages: the station (sender) broadcasts the message, and listeners can choose to listen in and receive some (or all) of the broadcast messages.
For example, you might have a network reachability check in your app delegate, and post notifications whenever the reachability changes. Other objects would listen for that notification and react accordingly when the network goes up or down.
Some Cocoa frameworks send notifications when certain events happen. In iOS 4.0 and up, the application sends notifications when an app is about to move the background... and when it returns from the background. Your app's objects and controllers can listen for these notifications and stop actions (or save data) when the app is about to quit, and resume when it becomes active again.









Normal Notification.

Step 1 : Register your Notification in class in which you want to use. Unregister its in same class when class is no longer.
Register
             [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(methodName) name:@"myNotificationFire" object:nil];
Unregister - Unresister it in class dealloc method or when notification is not in use.
                [[NSNotificationCenter defaultCenter] removeObserver:self];

Step 2 : Implement its register method 
  -(void) methodName{
      NSLog(@"Notification Method Call");
    }

Step 3 : Use that Notification.
     [[NSNotificationCenter defaultCenter] postNotificationName:@"myNotificationFire" object:nil]


Notification with object.

Step 1 : Register your Notification in class in which you want to use. Unregister its in same class when class is no longer.
Register
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(methodName:) name:@"myNotificationFire" object:nil];
UnRegister - Unresister it in class dealloc method or when notification is not in use.
           [[NSNotificationCenter defaultCenter] removeObserver:self];

Step 2 : Implement its register method 
  -(void) methodName:(NSNotification *)notification{

    NSMutableDictionary *dictionary =(NSMutableDictionary*) [notification object];
      NSLog(@"Notification Method Call.And object content is :%@", dictionary);
    }

Step 3 : Use that Notification.
     [[NSNotificationCenter defaultCenter] postNotificationName:@"myNotificationFire" object:ObjectName]
        //ObjectName that is object that you want to receive at notification receiver method. In our case its "methodName"


Additional References

Here is Apple Official document list for notification.
NSNotificationCenter

If any tip or new idea or change for iOs 7 NSNotificationCenter then please share with us.

Hope this will useful to you. If any suggestion then please write in comment . Thank You.

Wednesday 9 January 2013

Calendar - Multiple month

///Here is method to add multiple month into scroll view as like iPad Reminder application
//Replace your scroll view name

-(NSDate *)getCurrentDate{
   
    NSCalendar *calendar = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
   
    NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init];
    [dateFormat setCalendar:calendar];
    [dateFormat setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
    [dateFormat setTimeZone:[NSTimeZone systemTimeZone]];
   
    NSDateFormatter *dateFormatter = [[NSDateFormatter alloc] init];
    [dateFormatter setTimeZone:[NSTimeZone systemTimeZone]];
    [dateFormatter setDateFormat:@"yyyy-MM-dd HH:mm:ss"];
   
    return [NSDate dateWithTimeInterval:0 sinceDate:[dateFormatter dateFromString:[dateFormat stringFromDate:[NSDate date]]]];
}
-(void)addCalander
{
    NSDate *yourDate=[self getCurrentDate];
   
    float s=7000;
    float h=0;
    float heightSC=0;
   
    for(int m=0;m<=11;m++)
    {
        TKCalendarMonthView *calendar1=[[TKCalendarMonthView alloc] init];
        calendar1.delegate = self;
        calendar1.dataSource = self;
       
       
        NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
        NSDateComponents *todayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:yourDate];
        NSInteger theDay = [todayComponents day];
        NSInteger theMonth = [todayComponents month];
        NSInteger theYear = [todayComponents year];
       
        // now build a NSDate object for yourDate using these components
        NSDateComponents *components = [[NSDateComponents alloc] init];
        [components setDay:theDay];
        [components setMonth:theMonth];
        [components setYear:theYear];
        NSDate *thisDate = [gregorian dateFromComponents:components];


        h=calendar1.frame.size.height+2;
       
        // now build a NSDate object for the next day
        NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
        [offsetComponents setMonth:-1];
        NSDate *nextDate = [gregorian dateByAddingComponents:offsetComponents toDate:thisDate options:0];
        [calendar1 selectDate:nextDate];
        s=s-calendar1.frame.size.height+2;
               
        yourDate=nextDate;
        heightSC=heightSC+calendar1.frame.size.height+2;
    }
   
   
    yourDate=[self getCurrentDate];
    s=heightSC;
   
    for(int m=11;m>=0;m--)
    {
        TKCalendarMonthView *calendar1=[[TKCalendarMonthView alloc] init];
        calendar1.delegate = self;
        calendar1.dataSource = self;
       
        NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
        NSDateComponents *todayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:yourDate];
        NSInteger theDay = [todayComponents day];
        NSInteger theMonth = [todayComponents month];
        NSInteger theYear = [todayComponents year];
       
        // now build a NSDate object for yourDate using these components
        NSDateComponents *components = [[NSDateComponents alloc] init];
        [components setDay:theDay];
        [components setMonth:theMonth];
        [components setYear:theYear];
        NSDate *thisDate = [gregorian dateFromComponents:components];
        h=calendar1.frame.size.height;
        // now build a NSDate object for the next day
        NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
        [offsetComponents setMonth:-1];
        NSDate *nextDate = [gregorian dateByAddingComponents:offsetComponents toDate:thisDate options:0];
       
        [calendar1 selectDate:nextDate];
        s=s-calendar1.frame.size.height;
        UIView *view_c=[[UIView alloc]initWithFrame:CGRectMake(0, s, 224, calendar1.frame.size.height)];
       
        [self.view addSubview:scroll];
        [view_c addSubview:calendar1];
        [scroll addSubview:view_c];
        yourDate=nextDate;
    }
   
   
    //NSLog(@"s out is %f",s);
    yourDate=[self getCurrentDate];
    s=heightSC;
    for(int m=11;m<35;m++)
    {
        TKCalendarMonthView *calendar1=[[TKCalendarMonthView alloc] init];
        calendar1.delegate = self;
        calendar1.dataSource = self;
       
        NSCalendar *gregorian = [[NSCalendar alloc] initWithCalendarIdentifier:NSGregorianCalendar];
        NSDateComponents *todayComponents = [gregorian components:(NSDayCalendarUnit | NSMonthCalendarUnit | NSYearCalendarUnit) fromDate:yourDate];
        NSInteger theDay = [todayComponents day];
        NSInteger theMonth = [todayComponents month];
        NSInteger theYear = [todayComponents year];
        int fla=1;
        if(theDay==1){
            fla=0;
        }
        // now build a NSDate object for yourDate using these components
        NSDateComponents *components = [[NSDateComponents alloc] init];
        [components setDay:theDay];
        [components setMonth:theMonth];
        [components setYear:theYear];
        NSDate *thisDate = [gregorian dateFromComponents:components];
       
        // now build a NSDate object for the next day
        NSDateComponents *offsetComponents = [[NSDateComponents alloc] init];
        if(fla==0)
        {
            [offsetComponents setDay:32];
        }
        else
        {
            [offsetComponents setMonth:1];
        }
        NSDate *nextDate = [gregorian dateByAddingComponents:offsetComponents toDate:thisDate options:0];
        if(m==11)
        {
            nextDate=yourDate;
            calendarScrollingPosition = s;
        }
        [calendar1 selectDate:nextDate];
       
        UIView *view_c=[[UIView alloc]initWithFrame:CGRectMake(0, s, 224, calendar1.frame.size.height)];
       
       
        s=s+calendar1.frame.size.height+2;
       
        [self.view addSubview:view_c];
        [scroll addSubview:view_c];
        [view_c addSubview:calendar1];
       
        yourDate=nextDate;
    }
   
    scroll.contentSize=CGSizeMake(150, s);
    [scroll setShowsHorizontalScrollIndicator:NO];
    [scroll setShowsVerticalScrollIndicator:NO];
   
    [scroll setContentOffset:CGPointMake(0, calendarScrollingPosition) animated:NO];
}

Monday 7 January 2013

Audio - Play Sound File

 //Code to play audio from resource
    NSString *path = [NSString stringWithFormat:@"%@%@", [[NSBundle mainBundle] resourcePath], @"/test.wav"];//Replace with your sound file which is in resource file
   
    SystemSoundID soundID;
    NSURL *filePath = [NSURL fileURLWithPath:path isDirectory:NO];
    AudioServicesCreateSystemSoundID((CFURLRef)filePath, &soundID);
    AudioServicesPlaySystemSound(soundID);

Database - Select particular row with where condition

//TableName - Name of table
//withColumn - Array of column name to select
//withCondition - column name on which you want to make condition
//ComumnValue - what pass in that column
//Here is method for same
- (NSMutableArray *)columeFromDatabase:(NSString *)TableName withColumn:(NSArray *)arrColumnName withCondition:(NSString *)ColumnNameCondition withColumnValue:(NSString *)ColumnValue
{
    NSMutableArray  *resultArray = [[NSMutableArray alloc] initWithCapacity:0];
    NSString *strComma=@",";
   
    NSMutableString *query=[[[NSMutableString alloc]init] autorelease];
    NSMutableString *strtemp=[[[NSMutableString alloc]init] autorelease];
   
    [query appendString:@"SELECT "];
    for(int i=0;i<[arrColumnName count];i++)
    {
        [query appendString:[arrColumnName objectAtIndex:i]];
        [query appendString:strComma];
       
    }
    NSString *strQueryStar=[NSString stringWithFormat:@"%@",query];
    strQueryStar = [strQueryStar substringToIndex:[strQueryStar length] - 1];
    [strtemp appendString:strQueryStar];
   
    [strtemp appendString:@" FROM "];
    [strtemp appendString:TableName];
    [strtemp appendString:@" WHERE "];
   
    [strtemp appendString:ColumnNameCondition];
    [strtemp appendString:ColumnValue];
   
    const char *sql = [strtemp UTF8String];
    sqlite3_stmt *selectStatement;
   
    //prepare the select statement
    int returnValue = sqlite3_prepare_v2(database, sql, -1, &selectStatement, NULL);
    if(returnValue == SQLITE_OK)
    {
        sqlite3_bind_text(selectStatement, 1, sql, -1, SQLITE_TRANSIENT);
        //loop all the rows returned by the query.
        NSMutableArray *arrColumns = [[NSMutableArray alloc] initWithCapacity:0];
        for (int i=0; i<sqlite3_column_count(selectStatement); i++)
        {
            const char *st = sqlite3_column_name(selectStatement, i);
            [arrColumns addObject:[NSString stringWithCString:st encoding:NSUTF8StringEncoding]];
        }
        int intRow =1;
        while(sqlite3_step(selectStatement) == SQLITE_ROW)
        {
            NSMutableDictionary *dctRow = [[NSMutableDictionary alloc] initWithCapacity:0];
            for (int i=0; i<sqlite3_column_count(selectStatement); i++)                
            {
                int intValue = 0;
                double dblValue =0;
                const char *strValue;
                switch (sqlite3_column_type(selectStatement,i))
                {
                    case SQLITE_INTEGER:
                        intValue  = (int)sqlite3_column_int(selectStatement, i);
                        [dctRow setObject:[NSNumber numberWithInt:intValue] forKey:[arrColumns objectAtIndex:i]];
                        break;
                    case SQLITE_FLOAT:
                        dblValue = (double)sqlite3_column_double(selectStatement, i);
                        [dctRow setObject:[NSNumber numberWithDouble:dblValue] forKey:[arrColumns objectAtIndex:i]];                       
                        break;
                    case SQLITE_TEXT:
                        strValue = (const char *)sqlite3_column_text(selectStatement, i);
                        [dctRow setObject:[NSString stringWithCString:strValue encoding:NSUTF8StringEncoding] forKey:[arrColumns objectAtIndex:i]];                       
                        break;
                    case SQLITE_BLOB:
                        strValue = (const char *)sqlite3_column_value(selectStatement, i);
                        [dctRow setObject:[NSString stringWithCString:strValue encoding:NSUTF8StringEncoding] forKey:[arrColumns objectAtIndex:i]];                       
                        break;
                    case SQLITE_NULL:
                        [dctRow setObject:@"" forKey:[arrColumns objectAtIndex:i]];                       
                        break;
                    default:
                        strValue = (const char *)sqlite3_column_value(selectStatement, i);
                        [dctRow setObject:[NSString stringWithCString:strValue encoding:NSUTF8StringEncoding] forKey:[arrColumns objectAtIndex:i]];
                        break;
                }
               
            }
            [resultArray addObject:dctRow];
            [dctRow release];
            intRow ++;
        }
       
        [arrColumns release];
    }
   
    sqlite3_reset(selectStatement);
    return [resultArray autorelease];
}

UITableView - Reload table view with smooth animation

//Put this code where you want to reload your table view
dispatch_async(dispatch_get_main_queue(), ^{
        [UIView transitionWithView:<"TableName">
                          duration:0.1f
                           options:UIViewAnimationOptionTransitionCrossDissolve
                        animations:^(void) {
                            [<"TableName"> reloadData];
                        } completion:NULL];       
    });

Sunday 6 January 2013

UIImage - Merge two image

///Mearge two image in one image
-(UIImage *)imageWithImage:(UIImage *)image
                     borderImage:(UIImage *)borderImage
                    covertToSize:(CGSize)size
{
    UIGraphicsBeginImageContext(size);
    [image drawInRect:CGRectMake( 10, 0, 60, 53 )];
   
    [borderImage drawInRect:CGRectMake( 0, 0, 70, 70)];
    UIImage *destImage = UIGraphicsGetImageFromCurrentImageContext();   
    UIGraphicsEndImageContext();
    return destImage;
}


///How To Use
  ImageView.image=[self imageWithImage:Image1 borderImage:Image2 covertToSize:CGSizeMake(70, 70)];

MKMap - Add tap gesture on map pin and handle it

Here is code to handle tap gesture on map view and display data related to that when click on pin its directly display its related data.

///Add protocol for UIGestureRecognizerDelegate  

///Add on each pin in viewForAnnotation

 UITapGestureRecognizer *pinTap=[[UITapGestureRecognizer alloc]initWithTarget:self action:@selector(pinTapped:)];
 pinTap.numberOfTapsRequired=1;
 [yourPinView addGestureRecognizer:pinTap];

///Gesture Handle method
- (void)pinTapped:(UIGestureRecognizer *)gestureRecognizer
{   
    NSLog(@"%i",[gestureRecognizer view].tag);   
    NSLog(@"Write your code");
}

Thursday 3 January 2013

Keyboard - Add Done Button in Number Pad




//In this code you can add done button on you number key pad you need to handle its hide/show using boolean variable as per your requirement.
.h
==

UIButton * doneButton;
BOOL phoneTagOrNot;

.m
===
- (void)addButtonToKeyboard {
   
    // create custom button
    doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
    doneButton.frame = CGRectMake(0, 163, 106, 53);
    doneButton.adjustsImageWhenHighlighted = NO;
   
    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.0) {
        [doneButton setImage:[UIImage imageNamed:@"DoneUp3.png"] forState:UIControlStateNormal];
        [doneButton setImage:[UIImage imageNamed:@"DoneDown3.png"] forState:UIControlStateHighlighted];
       
    } else {
        [doneButton setImage:[UIImage imageNamed:@"DoneUp.png"] forState:UIControlStateNormal];
        [doneButton setImage:[UIImage imageNamed:@"DoneDown.png"] forState:UIControlStateHighlighted];
       
    }
   
    [doneButton addTarget:self action:@selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
   
    // locate keyboard view
    UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
   
    UIView* keyboard;
   
    for(int i=0; i<[tempWindow.subviews count]; i++) {
       
        keyboard = [tempWindow.subviews objectAtIndex:i];
       
        // keyboard found, add the button
        if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 3.2) {
            if([[keyboard description] hasPrefix:@"<UIPeripheralHost"] == YES)
                [keyboard addSubview:doneButton];
           
        } else {
            if([[keyboard description] hasPrefix:@"<UIKeyboard"] == YES)
                [keyboard addSubview:doneButton];
        }

        if (phoneTagOrNot == TRUE)
            doneButton.hidden = TRUE;
        else
            doneButton.hidden = FALSE;
    }
}