ios app screen messed up when back button is hit - ios

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];
}

Related

Unity - How to hide Homebar on iOS ( defer system gestures and hide home button )

The game is in landscape mode and at the bottom of the screen are some ui buttons, for this reason I would need to hide iPhone home bar and use deferred edges.
Using "Hide home button on iPhone X" correctly hides the button, but any single tap will show the bar and single swipe will close the game. Not good.
Using deferred system gestures only, behavior is correct, it takes two swipes to close the game. The problem is that the home bar is always visible, its greyed out, but always visible. Gets highlighted on a first swipe, closes game on the second. Thats good, but cant have visible home bar all the time, its right on top of the buttons. Not good.
Used deferred edges and Hide home button option is acting like 1), ie deferred edges are ignored for some reason. Not good.
Question: Is there some way to have home bar hidden and appear only on a swipe and on second swipe closes game. Ie functionality like 2) but the bar is hidden instead of greyed out?
In player settings under Resolution and Presentation you could check Render over native ui
This option will force unity to display app contents over the native ui, however then you need to setup a custom way to close your application.

when click back button navigated to every pages I visit

I have 5 screens.
The 5th screen has a button go to the 1st screen.
I clicked the 1st screen and 2nd screen and 3rd screen and 4th screen and 5th screen again clicked the 1st screen and 2nd screen and 3rd screen and 4th screen and 5th screen. (1>2>3>4>5>1>2>3>4>5)
I clicked back button again and again.not stopping in 1st page. go to I visited every page. (5<4<3<2<1<5<4<3<2<1)
I used WillPopScope
When you are going from 5th screen to 1st screen, you should not push the 1st screen. Instead, you should use popUntil to pop until you get back to 1st screen.
For this, you're going to have to add a named route to 1st screen, so that you can use something like ModalRoute.withName('/login') as shown in the example here.
This question seems to be closely related: Flutter Navigation pop to index 1

iOS keyboard prevent UIButton from reacting

I have 3 views illustrated as in the image. View 2 is in View 1, and View 3 is in View 2. Something weird is happening:
When I click the textfield in View 3, the keyboard opens, and at this time the button in View 2 no longer reacts. When I click button 2 with keyboard open, its color changes (notifies me it is clickable), but the event is never fired. If I don't click the textfield to open keyboard, button functions normally, color changes and the event is fired.
However, button 1 in View1 always works normally, doesn't get affected by the keyboard. It took me a while to find out it's the keyboard that makes the difference but I just can't figure out why. Could someone help me a little?

View doesn't come back to normal position when 'little keyboard' button is clicked on the keyboard - iPad, Xcode

I have a view with 2 text box's for id and password. When the user tries to enter fields, view will move up and the keyboard will pop up. After clicking 'NEXT' pointer moves to the second text box, and when DONE is clicked everything goes back to normal position. Everything is working perfect until here.
But what's happening is, when i click on the little keyboard icon in the very bottonm right of the keyboard, keyboard is disappearing but the view stays in the same position and doesn't animate down.
I have the code for animating based on the initial position of the view
//Condition to execute when the keyboard is initially clicked
if (_pagerView.frame.origin.y == _pagerFrame.origin.y)
//Condition to execute when the 'Done' Button is clicked
if (_pagerView.frame.origin.y != _pagerFrame.origin.y)
What i need is, the view to come down to normal position when the little keyboard is clicked.Thanks

Tapping background to close subview in Xcode 4.3

Currently I am creating an app. for the ipad that uses a media player. When you click on a button the media player pops up and I have code that when you press another button the media player stops and is hidden so you can go back to using the superview. The problem is, I dont want to have to click a button to close the subview, I want to be able to click anywhere on the background to close. I've tried making the whole background a button but I'm having trouble writing code to make it so that the full window button that closes the subview ONLY appears when the subview is up. Right now the full window button is up constantly so I can't click on the button that brings up the subview in the first place because the large button is overlapping. I hope this dilemma is fairly easy to understand. If not I can send some code.
Try a UIPopover instead. What you're describing is the default behavior.

Resources