Keyboard Done button in iphone

Ads
 

Keyboard Done button in iphone

hii,,

how can i set a function on press keyboard done button.

View Answers

October 28, 2010 at 12:09 PM

hello,

For making keyboard Done button press :-

import keyboard displacement by adding this line

#define kOFFSET_FOR_KEYBOARD  80.0

here you can set 80.0 according to your need

-(void)textFieldDidBeginEditing:(UITextField *)sender
{

    if ([sender isEqual:TextField])
    {

        if  (self.view.frame.origin.y >= 0)
        {
            [self setViewMovedUp:YES];
        }
    }
}

-(void)setViewMovedUp:(BOOL)movedUp
{
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];  
    CGRect rect = self.view.frame;
    if (movedUp)
    {
                rect.origin.y -= kOFFSET_FOR_KEYBOARD;
        rect.size.height += kOFFSET_FOR_KEYBOARD;
    }
    else
    {
        // revert back to the normal state.
        rect.origin.y += kOFFSET_FOR_KEYBOARD;
        rect.size.height -= kOFFSET_FOR_KEYBOARD;
    }
    self.view.frame = rect;

    [UIView commitAnimations];
}


- (void)keyboardWillShow:(NSNotification *)notif
{


    if ([TextField isFirstResponder] && self.view.frame.origin.y >= 0)
    {
        flag=YES;

        [self setViewMovedUp:YES];
    }
    else if (![TextField isFirstResponder] && self.view.frame.origin.y < 0)
    {
        [self setViewMovedUp:NO];
    }
}




- (void)viewWillAppear:(BOOL)animated
{
    // register for keyboard notifications
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector

(keyboardWillShow:)

                 name:UIKeyboardWillShowNotification object:self.view.window]; 
}

- (void)viewWillDisappear:(BOOL)animated
{
    // unregister for keyboard notifications while not visible.
    [[NSNotificationCenter defaultCenter]

removeObserver:self name:UIKeyboardWillShowNotification object:nil]; }

-(void) touchesBegan :(NSSet *) touches withEvent:(UIEvent *)event
{

    //NSLog(@"%@",flag);
    if (flag==TRUE)
    {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.5];
    CGRect rect = self.view.frame;
    rect.origin.y += kOFFSET_FOR_KEYBOARD;
    rect.size.height -= kOFFSET_FOR_KEYBOARD;
    self.view.frame = rect;

    [UIView commitAnimations];
        flag=FALSE;
    }
    [TextField resignFirstResponder];
        [super touchesBegan:touches withEvent:event ];
}

Ads









Related Tutorials/Questions & Answers:
uikeyboard done button/return button
uikeyboard done button/return button  Hi everyone!!! Just worried about ..how to return the UIKeyboard on done or return button click in my iPhone...; button2.delegate = self; } // dismiss the keyboard then the "done" button is clicked
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
Advertisements
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
hide show keyboard iphone
hide show keyboard iphone  How to hide show keyboard in iPhone programmatically
hide keyboard iphone
hide keyboard iphone  Can anyone tell me how to hide keyboard in my simple view based application in iphone?   Hiding keyboard in iPhone - (BOOL)textFielsShouldReturn:(UITextField *)textField { [textField
uitableview edit done button
uitableview edit done button  How to add Edit / Done button in UITableView with an action on click?   UITableview Edit done Button To add " Edit / Done button " in UITableView add the given code in UIView Controller
handling Button Event in iphone
handling Button Event in iphone  handling Button Event in iphone
info button iphone example
info button iphone example  I'm looking for a simple info button example in iPhone XCode. Thanks
home button macbook pro keyboard
home button macbook pro keyboard  what is the substitute of Home and End button on macbook pro keyboard?   Home = Function Key (Fn) + Left Arrow End = Function Key (Fn) + Right Arrow
iphone button click event
iphone button click event  Hi, How to write iphone button click event? Thanks   Hi, Here the method declaration: -(IBAction) myMetod...{ NSLog(@"Button clicked"); } Thanks
iPhone Radio Button Example
iPhone Radio Button Example  Can you please suggest me how to create Radio button in my iPhone application. Actually, in my application i have two... click on that button it get selected and by default it should display unselected
How to Create Button With TableView in iphone
How to Create Button With TableView in iphone  My requirement is i am creating one button. when i press the button TableView will display... on the button can u please send me the code i want to create converter app. thanks
uitextfield hide keyboard on return
the keyboard when use clicks on the return button of the iPhone keyboard. Thanks...uitextfield hide keyboard on return  I am working on a iPhone project. I want to hide the keyboard when use clicks on the return button of the IOS
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???  How can change Button Label value Every Time when i start Virtual Keyboard, Means ,if 1st time Button1=''a'' then next login time
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???
How can i Change Button Label Value Randomly in VIRTUAL KEYBOARD using JAVA or Net Beans ???  How can change Button Label value Every Time when i start Virtual Keyboard, Means ,if 1st time Button1=''a'' then next login time
resign first responder keyboard
resign first responder keyboard  Hi, How I can hide keyboard on click on of done button in keyboard. Give me example of resign first responder keyboard example code. Thanks   Hi, Make your controller delegate to text
iphone
iphone  How can connect with the other database in iphone application(like... MYsql or oracle) is this dirctly possible
uitextfield disable keyboard
uitextfield disable keyboard  How to disable keyboard of UITextView in iPhone SDK application?   There are two ways to disable the keyboard of UITextField in iPhone SDK application - (BOOL)textFieldShouldBeginEditing
Google Android G1 vs Apple iPhone 3G
built on completely different platforms. Although the iPhone 3G has done pretty... customisable controls and a QWERT keyboard for easy navigation the iPhone still features easier control and navigation on its button-less and physical keyboard
button
button  can i give multiple commands on click of a button? if yes how can i do that?? multiple commands can we retriving dat from database, capturing data, moving to next page.. etc
button
button  can i give multiple commands on click of a button? if yes how can i do that?? multiple commands can be retriving dat from database, capturing data, moving to next page.. etc
How to connect on screen keyboard to system.
How to connect on screen keyboard to system.  How to connect on screen keyboard to system.I made on screen keyboard in java(swing).Now i want connect to system means when i pressed any button then it type on notepad or any
How to connect on screen keyboard to system.
How to connect on screen keyboard to system.  How to connect on screen keyboard to system.I made on screen keyboard in java(swing).Now i want connect to system means when i pressed any button then it type on notepad or any
iPhone Development
iPhone Development Apple Inc. in June 2007 had created a revolution by launching an incredible internet mobile phone, iPhone that had some amazing features like virtual keyboard, wireless internet connection through 3G spectrum
keyboard input
keyboard input  how do I use JOptionPane to accept keyboard input? I know how to import but not specific command on input line   import javax.swing.*; class JOPtionPaneExample { public static void main(String
How to display windows virtual keyboard
How to display windows virtual keyboard  Hi, I have a jsp file which contains my website design. In my jsp website design, there's a button. I need to display windows virtual keyboard when i press the button. how to do
ModuleNotFoundError: No module named 'done'
ModuleNotFoundError: No module named 'done'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'done' How to remove the ModuleNotFoundError: No module named 'done' error
ModuleNotFoundError: No module named 'done'
ModuleNotFoundError: No module named 'done'  Hi, My Python program is throwing following error: ModuleNotFoundError: No module named 'done' How to remove the ModuleNotFoundError: No module named 'done' error
ModuleNotFoundError: No module named 'keyboard'
ModuleNotFoundError: No module named 'keyboard'  Hi, My Python... 'keyboard' How to remove the ModuleNotFoundError: No module named 'keyboard... to install padas library. You can install keyboard python with following
What is iPhone
control everything without pushing a button! Type using the predictive keyboard...;   Intelligent Keyboard: The iPhone keyboard is only visible when you... 21 languages. The full QWERTY iPhone keyboard let's you type fast without
calling from iphone through programitically in iphone
calling from iphone through programitically in iphone  calling from iphone through programitically in iphone please help me my senario is if i click send sms button message should deliver to xyz person and that xyz person make

Ads