Monday 25 March 2013

Add Done Button on Numeric Keyboard in Xcode

Here is following code you have to use to add a Done button on Numeric Keyboard

In .h file you have to add a new Button named Done

  UIButton *doneButton;


After this you have to implement following code in .m file


- (void)addButtonToKeyboard {
    // create custom button
    if (doneButton == nil) {
        doneButton  = [[UIButton alloc] initWithFrame:CGRectMake(0, 163, 106, 53)];
    }
    else {
        [doneButton setHidden:NO];
    }

    [doneButton addTarget:self action:@selector(doneButtonClicked:) forControlEvents:UIControlEventTouchUpInside];
    // locate keyboard view
    UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
    UIView* keyboard = nil;
    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];
        }
    }
}
- (void)doneButtonClicked:(id)Sender {
   // Here we'll write our code to for button action
}

Thursday 21 March 2013

iOS - Rate the App in AppStore


Unzip the iRate-master.zip --> Click the iRate-master folder  --> Click the iRate Folder --> Select the all files into your project.
In iRate Folder has Files are

        1. iRate.bundle
        2. iRate.h
        3. iRate.m

Step 1:
Create a new project --> Name as rate me & tick the use automatic reference counting 


                                                   (or)

Existing Project --> select the Project --> click the target(Project Name) --> Selct the buildPhases --> Compiled Sources --> double click the iRate.m --> Type the -fobjc-arc




Step 2:
AppDelegate.m

#import "iRate.h"

+ (void)initialize
{
    //configure iRate
    [iRate sharedInstance].applicationBundleID = @"com.company.appname";// Replace this
    [iRate sharedInstance].usesUntilPrompt = 4;
    [iRate sharedInstance].previewMode = YES;
}


Button Coding to Rate your App:
-(IBAction)action_rate:(id)sender
{
    [[iRate sharedInstance] openRatingsPageInAppStore];
}