문제

I have this scroll view problem.I have 2 screens in my app, Screen A and Screen B. I have 10 buttons on my first Screen A. They all are placed on a scroll view. I also have 2 UITextViews at the bottom right corner of the screen. When i click in the textivew to enter value it brings up the keyboard. Now without closing/hiding the keyboard i am clicking a button on my app.This takes me to a different screen, screen B. There i have a textfield and an add button. I click in the textfield and a keyboard shows up. I enter the value.Click the add button. It adds the entered value to a tableview i have on that screen.Now without closing/hiding the keypad on this screen as well i hit back button.So i am back in screen A. But now the screen is distorted. All fields are scrolled way up to the screen.There is a white space about 50-60% of screen at the bottom. I followed this link http://www.techotopia.com/index.php/Writing_iOS_5_Code_to_Hide_the_iPhone_Keyboard It worked in the morning for screen B.I hit back and it brought me to screen A and without any abnormal screen. Why is it happening?Doing the steps in that link will suffice? Or is it not that simple and i have to do somemore steps?Please help .Thanks..

EDIT: So i noticed a pattern.I enter value in UItextview.Click button on screen A, move to screen B .Add value here also .Click back then brought back to screen A and view is all messed up. So i did this testing 1.Change UITextview value (keyboard pops up),just click button ->screen B.Do nothing on screen B.Hit back.Screen A is fine. 2.Hit button on screen A without changing anything on UItextview (no keypad pops up).Move to screen B.Do nothing here and hit back to screen A. Screen A appears and is perfect. 3.Hit button Screen A without changing anything on UITtextview (no keypad pops up).Move to screen B. Enter value in textfield. Click add button.Hit back.Come back to screen A. Screen A is fine. 4.Change value of TextView(Keypad pops up).Without hiding/closing this, hit button.Screen B appears.Enter value in textfield(keypad pops up).Click Add Button. Click back. Come back to screen A. Screen A is messed up. In summary when i change values/ or when keypad appears in both screens screen A is messed up. Can someone help me out?

도움이 되었습니까?

해결책

[self.view endEditing:YES]; does the trick. I added this in viewWillDisappear like this on both the screens.

- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
[self.view endEditing:YES];
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top