How to make view automatically scroll when keyboard show up

Hi all
I'm like a totally noob for objective-c coding, let alone the iPhone programing. :P
Anyway, I somehow manage to create a simple application that receive input via UITextField, do some simple math, then display the result in other UITextFields (which can act as a input vice versa).
Problem is, when I use the UITextField at the buttom of the screen as an input, the keyboard will block that text field out of my view, so I could not see what I'm typing at all.
That's the question. How to make my view scrollable, and make it simply scroll itself out of the way when the keyboard is shown? I already inherit my view from UIScrollView, but don't know what to do next. Can you guys help enlighten me, please?
Thanx

Of course, if you're dealing with textFields, you should change a few things try something like that in your .m file :
- (void)textFieldDidBeginEditing:(UITextField *)theTextField
if ([theTextField isEqual:yourTextField])
// Restore the position of the main view if it was animated to make room for the keyboard.
if (self.view.frame.origin.y >= 0)
[self setViewMovedUp:YES];
// Animate the entire view up or down, to prevent the keyboard from covering the author field.
- (void)setViewMovedUp:(BOOL)movedUp
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
// Make changes to the view's frame inside the animation block. They will be animated instead
// of taking place immediately.
CGRect rect = self.view.frame;
if (movedUp)
// If moving up, not only decrease the origin but increase the height so the view
// covers the entire screen behind the keyboard.
rect.origin.y -= kOFFSETFORKEYBOARD;
rect.size.height += kOFFSETFORKEYBOARD;
else
// If moving down, not only increase the origin but decrease the height.
rect.origin.y += kOFFSETFORKEYBOARD;
rect.size.height -= kOFFSETFORKEYBOARD;
self.view.frame = rect;
[UIView commitAnimations];
- (void)keyboardWillShow:(NSNotification *)notif
// The keyboard will be shown. If the user is editing the author, adjust the display so that the
// author field will not be covered by the keyboard.
if ([yourTextField isFirstResponder] && self.view.frame.origin.y >= 0)
[self setViewMovedUp:YES];
else if (![yourTextField isFirstResponder] && self.view.frame.origin.y < 0)
[self setViewMovedUp:NO];
#pragma mark - UIViewController delegate methods
- (void)viewWillAppear:(BOOL)animated
// watch the keyboard so we can adjust the user interface if necessary.
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:)
name:UIKeyboardWillShowNotification object:self.view.window];
- (void)viewWillDisappear:(BOOL)animated
[self setEditing:NO animated:YES];
// unregister for keyboard notifications while not visible.
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIKeyboardWillShowNotification object:nil];
be sure to invoke the method when you dismiss the keyboard, so that the view "falls back" to its normal state:
if (self.view.frame.origin.y < 0)
[self setViewMovedUp:NO];
Of course, declare the method
(void)setViewMovedUp:(BOOL)movedUp;
in the .h file
and the #define you will use in you .m file :
// the amount of vertical shift upwards keep the text field in view as the keyboard appears
#define kOFFSETFORKEYBOARD 50.0
// the duration of the animation for the view shift
#define kVerticalOffsetAnimationDuration 0.30
good luck !

Similar Messages

  • How do i make WebView automatically load when using TakeStringURLFrom??

    I haven't added any code yet. I've WebKit, a Webview and a editable textbox where it takes the URL from. Normally it would require you to hit enter, but i would like it to just load it automatically. How do i do this? Please explain EXACTLY how! I would also like to know how instead of it using scrollers, i can make it just do like if you play a windowed game, u know, so u can still see it all. Also i would like to know how u make it stretch out when it enters fullscreen, please.

    Open Accounts preferences, click on the Login Items tab. Select entries and press Delete [-] to remove. Click on the Add [+] button to place an application into the list.
    Note that the more items in the list you load at startup the slower your startup time will be.

  • When keyboard show-up view didn't resize in Android, ADF Mobile

    Hi Guys,
    Now I was facing with amx page didn't resize when keyboard pop-up, so user cannot scroll for more fields below,
    Btw iOS is normal to resize when keyboard shown.
    How to fix this issue ?

    Hi Frank
    Thanks for reply, I have another issue about android startup performance with release mode, I will send it to you.
    Btw about Android resize view when keyboard show-up, I can fix it but it should include in next release of ADF Mobile.
    My fix is (Thanks for JoeHuang's way to browse Android template file : Google Play Store does not accept ADF Mobile apps for tablets)
    - Navigate to file <JDev Install>/JDeveloper/JDev/Extensions/oracle.adf.mobile/Android/Oracle_ADFmf_Framework.zip
    - Make a backup copy of the zip file
    - Unzip the file, which would extract all files into a "framework" directory
    - Navigate to framework/template/AndroidManifest.template.xml file
    - Change android:windowSoftInputMode value to "adjustResize" Ex. android:windowSoftInputMode="adjustResize"
    - Zip up the framework directory and name zip file as Oracle_ADFmf_Framework.zip, replacing the old one.  Please make sure the zip file has the exact same directory structure as before.
    - In JDeveloper, before deploying the application again, please do a "Clean All" to clean out all old deployment artifacts.
    - Deploy the app again
    After fix, views is automatically resize when keyboard pop-up, but seems weird with navigation bar that will show as it include in view too.
    I don't know why ADF Mobile put android:windowSoftInputMode value as "adjustPan" in manifest file, as Android document said as view will not resize when keyboard showing (Ref: http://developer.android.com/guide/topics/manifest/activity-element.html#wsoft)

  • How to make VM to suspend when it not use , VDI3.0 with SGD 4.5

    Hi All,
    We are using SunVDI3.0 with VBox 2.0.10 and connecting via SGD 4.5.
    i konw that we can do suspending vm on vmware esx, however i couldn't find it in VirtualBox provider.
    how to make VM to suspend when vm is not using for some period time.
    thanks in advance
    -kevin-
    Edited by: kevin on Sep 27, 2009 5:44 PM

    Hi All,
    We are using SunVDI3.0 with VBox 2.0.10 and connecting via SGD 4.5.
    i konw that we can do suspending vm on vmware esx, however i couldn't find it in VirtualBox provider.
    how to make VM to suspend when vm is not using for some period time.
    thanks in advance
    -kevin-
    Edited by: kevin on Sep 27, 2009 5:44 PM

  • How to make the Smooth Scrolling work even H Swipe is tick?

    In my article, if I tick the H Swipe only and the Smooth Scrolling is Both direction, Why is it in previewing it in my iPad the Scrolling seems Off because it's snapping into the pages.
    Smooth scrolling is not working if H Swipe only is tick.
    How to make the Smooth Scrolling work even H Swipe is tick?

    Horizontal scrolling is only for 1024x768 or 768x1024 pages. That’s it.
    You cannot combine horizontal only with smooth scrolling.
    Bob

  • I'm having a problem with the application Dropbox and I want to uninstall it. In finder it does not allow me to move it to trash telling me the dopbox application is open. How do I close it? when it shows up nowhere as an open application?

    I'm having a problem with the application Dropbox and I want to uninstall it. In finder it does not allow me to move it to trash telling me the dopbox application is open. How do I close it? when it shows up nowhere as an open application?

    Is there a DropBox icon up in the menubar you can click on & see quit DropBox?
    https://www.dropbox.com/help/41

  • How can i unlock my ipad when it show connect to itunes

    how can i unlock my ipad when it show connect to itunes

    Force iPad into Recovery Mode. Follow step 1 to 6 very closely.
    http://support.apple.com/kb/HT1808
    Note: You may have to repeat the above a few times.

  • How to prevent iPhoto to make an automatic event when importing from Photo stream

    Hi everyone,
    My question is related to the Photo stream functionality in iPhoto.
    Is possible to prevent iPhoto from making an automatic event when I import a photo from Photo stream. It is really annoying because of the fact that I use "events" for keeping my important photo's together (as many of you do I asume). Ofcourse after importing I can just delete it from my event section but is there a way to prevent it?
    Thanks.

    No. Photostream creates an Event for each month.
    iPhoto has many other tools for managing and categorising your Photos.
    I use Events simply as big buckets of Photos: Spring 08, July - Nov 06 are typical Events in my Library. I use keywords and Smart Albums extensively. I title the pics broadly.
    I keyword on a
    Who
    What
    Where basis (The When is in the photos's Exif metadata). I also rate the pics on a 1 - 5 star basis.
    Using this system I can find pretty much find any pic in my 40k library in a couple of seconds.
    So, for example, I have a batch of pics titled 'Seattle 08' and a  typical keywording might include: John, Anne, Landscape, mountain, trees, snow. With a rating included it's so very easy to find the best pics we took at Mount Rainier.
    File -> New Smart Album
    set it to 'All"
    title contains Seattle
    keyword is mountain
    keyword is snow
    rating is 5 stars
    Or, want a chronological album of John from birth to today?
    New Smart Album
    Keyword is John
    Set the View options to Sort By Date Ascending
    Want only the best pics?
    add Rating is greater than 4 stars
    The best thing about this system is that it's dynamic. If I add 50 more pics of John  to the Library tomorrow, as I keyword and rate them they are added to the Smart Album.
    In the end, organisation is about finding the pics. The point is to make locating that pic or batch of pics findable fast. This system works for me.
    Regards
    TD

  • How to make Finder automatically go to the foremost open window?

    I hope I'm explaining this clearly.
    Suddenly, when I click on the Finder from the Dock, it does not go to the last open window. I have to go to the Windows menu and select it, or click and wait on the Finder icon in the dock for it to open. I usually have a lot of apps open so when I go to Finder it's to do some file management - and the extra step of having to bring the last open window to the forefront is annoying me!
    Does anyone know how to make the Finder automatically come to the forefront (with the windows) from click in the Dock? I swear my mac always did that before but now it's stopped!

    can anyone help me here?

  • How to make "Submit" features disappear when form is distributed?

    Hi, I am very new at this. I'd like to know how to make the purple header that appears when a form has been distributed go away. This section says "Please fill out the following form. When finished, click Submit Form to return the completed form. Our company has been having problems when people submit these automatically, so we'd like to have them save them as PDFs and submit them as an attachment on an email. We don't want there to be any confusion about this, but I know that the forms have to be distributed so they can fill them out, and this purple header appears after I distribute. What do you suggest?

    You need to be a little more specific as to what is going on with the form. What is the exact issue you are having with the form when it is sent back? If your form is  designer form that is fillable then the header will always be there. It says "Please fill out the following form. If you are a form author, choose DistributeForm in the Forms menu to send it to your recipients."
    If you would like I could take a look at the form to see what you are experiencing. I have been designing forms for a major insurance company for four years and have come across many issues. In ordder to troubleshoot these issues you have to explain exactly what is happening to get at the root cause. It may something as simple as not having the submit button on the form or a little script written that saves the form as a save as.
    Not knowing the exact issue people are not going to be able to give you a fix. It is like taking your car to the mechanic and saying it doesn't work.

  • Viewing Calendar Reminders When Keyboard is Locked

    Does anyone know how to enable viewing calendar reminders on the screen even if the keyboard is locked? The default behavior is that I get an audio tone to let me know I have a meeting, but can't see any info when the keyboard is locked. It would be much more helpful if the reminder popped up and could be seen without first needing to unlock the keyboard. I have the 8830 on Verizon.
    Thanks

    The only thing you can do when the device is locked is to place outgoing calls. All other functions will only be available when the device is unlocked
    If someone has been helpful please consider giving them kudos by clicking the star to the left of their post.
    Remember to resolve your thread by clicking Accepted Solution.

  • How to make screen field enable when table control gives an error

    Hi,
        I had a scneario like when table control data wrong then one parameter of the screen should be enabled for the input, i knew that screen-name will not work since it will have always table control fields only when table control gives an error.
    How to make the other parameter enable when table control throws an error.
    Regards,
    Jaya

    Hi Gobi,
         Thanks for your response, but issue is - how to make other screen fields enable when there was an error in the table control data.
    For table control - lets say we will use the code as i mentioned above.i am sure that we cant write the code for field enable in between loop & endloop.
    as you said if we right outside the loop-endloop, the module wont be triggered when table control throws an error, because that statement was not there in the loop-endloop.
    please let me know if you need any more information on the issue. I hope there is alternative for this in SAP.
    Thanks
    Jaya

  • How to make finder side scroll?

    i did it once, but when i deleted the pref file( in a bad finder situation), so now i forgot how i made it to scroll side. Anyone, thanks in advance!

    I'm afraid I don't understand what you are talking about. Can you post a picture on a .me or flickr account and give us a URL to the image to point to us what you are talking about? Screen captures are done as described here:
    http://www.zimbio.com/MacOS+X+version+10.5+Leopard/articles/13/Mac+OS+X+screen+capturetips

  • How to make frame automatically size

    Hi,
    I'm developing a dialog using JFrame , but i'm setting the size of it.Is it possible to make it automatically size as and when i add compoments.
    thanks
    Raj

    use pack().
    Ashish

  • How to make the page expired when user click back

    how to make the page as expired when i click back button on the browser.
    i want a better way.
    actually i have a timer.when it reaches 00.00 then the expired page will be called automaticlly using location.href="expired.jsp" then if the user clicks back it should not show the previous page.this concept is applied with paging concept
    response.setheader is not working ...
    i have redirect when click back using
    <body onunload>....i call another page here.
    but it is not a good way.
    so pls help me to solve this problem
    using session or another good way

    Use this instead.
    Frame.setDefaultCloseOperation(javax.swing.WindowConstants.DO_NOTHING_ON_CLOSE);

Maybe you are looking for

  • My iCloud Account did not change to my new Apple ID. What do I do now?

    My iCloud account did not change from my old Apple ID to the new Apple ID, that I recently set up. What do I do now?

  • What are the benefits of having two video cards?

    I currently have a PNY Nvidio quadro FX 3800 video card installed.  I have another card that is not installed.  It is an EVGA E-GEforce 8800GT.  I only want to run two monitors.  I am thinking with two video cards I will have live preview on screen d

  • How do I manually uninstall FIM Portal and Service 2010

    I installed Forefront Identity Manager 2010 as follows: Server 1: FIM Sync Service Servers 2, 3: SharePoint Farm, FIM Portal and Service I've had issues from the installation. When installing FIM Portal and Service on Server 2 it failed to recognize

  • Hide  button in webdynpro standard

    Hi friends,     In the past some folks guided me to hide and change standard buttons; now I'm stuck with a toolbar which does not respond to my code when I want to hide it   Im enhancing webdybpro HRECM00_PLANNING_UI method WDDOMODIFYVIEW of view v_p

  • Cannot search anymore in the forum

    Hi, I can't use the search function anymore in this forum. It just return nothing. Quentin