Tuesday, 19 November 2013

iOS7 navigationbar Color properties

How to change iOS7 navigationbar color

self.navigationController.navigationBar.barTintColor = [UIColor blackColor]; self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; [self.navigationController.navigationBar setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
self.navigationController.navigationBar.translucent = NO; 

Monday, 21 January 2013

Gzip in Objective C

Reduce client side download time 

Gzip is a compression technique better than zip . The main advantage of gzip is to upload/download data from server to client quickly. All enterprise application uses XML or JSON and the size of the XML or JSON is very big and client side will take more time to download/upload data from server, to reduce the download/upload time GZipped data is needed.
   GZip compression will reduce download and upload time from server to client and client to server respectively.
Gzip will compress XML /JSON/ HTML data upto 60% ,so its very lighter on wire to download from client side.
To improve the performance of application, can send the gziped sqlite file from server to client, then its easy to download and use the sqlite directly.

GZip in iOS :-
https://github.com/nicklockwood/GZIP


Reference :-
http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/

Wednesday, 3 October 2012

Difference between Nil , nil and NULL

Difference between Nil , nil and NULL


nil is a null pointer to an Objective-C object
Nil is a null pointer to an Objective-C class. 
NULL is  a null pointer to anything else
 Actually all the three have the numeric value of 0.
  • nil == (id) 0 
  • Nil == (Class) 0 
  • NULL == (void *) 0 

simply can say that nil is a pointer to an object
    for example : 
     NSArray *array = [NSArray arrayWithObjects:@"karthik", @"prabhu", nil];

Friday, 28 September 2012

Types of Webservices

Big Webservice
     Big web service uses SOAP standard to communicate between client and server. SOAP is a XML based protocol running on top of HTTP. SOAP(Simple Object Access Protocol) is a communication protocol allow us to bypass firewall, main advantage is a platform independent and language independent.

   SOAP Message is a XML document
Four Tags in SOAP are
  • An Envelope (required) element that identifies the XML document as a SOAP message
  • An optional Header element that contains header information
  • A Body (required) element that contains call and response information
  • An optional Fault element containing errors and status information
<?xml version="1.0"?>
<soap:Envelope xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
<soap:Header>

</soap:Header>
<soap:Body>

  <soap:Fault>
 
  </soap:Fault>
</soap:Body>
</soap:Envelope>

WSDL (Web Services Description Language) is an XML-based language for locating and describing Web services.
     By using online tool http://sudzc.com/ we can convert our WSDL to ObjectiveC for iOS Project. This will automatically create and handle SOAP request , SOAP response respectively based on the WSDL.


RESTful Webservice
         REST stands for Representational State Transfer . RESTful web services are based on HTTP protocol and its methods are GET, POST,PUT and DELETE. REST is not a protocol and not a standard just a architecture style to communicate between client and server.

UIKeyBoard SplitView mode notification in iPAD

NSNotificationCenter is used to find the UIKeyBoard show or hide notification. From iOS5 can get the keyboard change notification (UIKeyboardDidChangeFrameNotification). Normally UIKeyboard have three modes are
 

  •        Dock
  •        UnDock
  •        Split


 Can find the keyboard show or hide notification by using name UIKeyboardWillHideNotification and UIKeyboardDidShowNotification for DOCK and UNDOCK mode.
In the split view, have to use UIKeyboardDidChangeFrameNotification to find the keyboard showor hide notification.


Register the notification in your  view controller to find keyboard changes in split view mode


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];

NSString *version = [[UIDevice currentDevice] systemVersion]; 
    float version_float = [version floatValue];

        if( version_float > 5.0])  //use notification if system version iOS5 and above
            [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShoworHide:) name:UIKeyboardDidChangeFrameNotification object:nil];

        [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardDidShowNotification object:nil]; 


In the keyboardWillShoworHide method implementation have to check for the keyboard showing or hiding

BOOL wasKeyboardVisible;
- (void) keyboardWillShoworHide:(NSNotification *)aNotification
{
    NSDictionary* info = [aNotification userInfo];
    
    CGRect currentKbRect = [[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue];
    
    CGRect screenRect = [[UIScreen mainScreen] bounds];
    
    BOOL keyboardVisible = CGRectIntersectsRect(currentKbRect, screenRect);
    
    if (keyboardVisible && !wasKeyboardVisible) {
        
     //keyboard visible
        
    } else if (!keyboardVisible && wasKeyboardVisible) {
    //keyboard hidden
    }
  
    wasKeyboardVisible = keyboardVisible;
   
}


Thursday, 27 September 2012

How to Custom UIKeyBoard for UITextField


                          Custom UIKeyboard 


   UITextField contains two properties

   
       // set while first responder, will not take effect until reloadInputViews is called.
@property (readwrite, retain) UIView *inputView;             
@property (readwrite, retain) UIView *inputAccessoryView;


inputView


Can use our custom UIView instead of system keyboard by using inputView property, create your own  UIView and assign to the inputView property.
  
              yourtxtfield.inputView = yourCustomKeyboardUIView;  
      
can switch our custom keyboard and  system keyboard by using  reloadInputViews (Updates the custom input and accessory views when the object is the first responder)

  change custom keyboard to system keyboard

            yourtxtfield.inputView = nil;
            [yourtxtfield  reloadInputViews];

 change system keyboard to custom keyboard
    
            youttxtfield.inputView = yourCustomKeyboardUIView;
            [self.kbtxtfield reloadInputViews];

       
replaced system keyboard by our custom UIView

inputAccessoryView

Can add a toolbar like view on top of system keyboard by using inputAccessoryView property, create your own UIView and assign to the property.

              yourtxtfield.inputAccessoryView = yourCustomtoolbarlikeUIView;
       
added toolbar like view on top of system keyboard using inputAccessoryView




This sample describes how to add a toolbar(input AccessoryView) on top of system keyboard and how to add a custom keyboard by replacing system UIKeyboard. you can also switch between custom view and system keyboard ,this sample used xib for custom keyboardview and inputAccessoryView, also describes that how to use Custom UIView and  XIB UIView.


download source code : https://github.com/karthikprabhuA/CustomKeyboardInputView-Sample
   

TOAST in iOS

iOS toast is a small popup without ok button which is similar to Android TOAST. It only fills the amount of space required for the message and the current view remains visible and interactive.

Download the source code from my github https://github.com/karthikprabhuA/Toast_iOS/

By using AKPToast class you can easily create a Android like TOAST message in iPhone/iPad application.
How to use :-
//center position toast
AKPToast* toast = [[AKPToast alloc]initWithText:@"Please wait.." toastView:self.view position:CENTER duration:SHORT];
toast.delegate = self; //you can get the toast completion event in the delegate -(void)toastCompletionDelegate
[toast show];