I have a view controller that when a subclass UIButton is tapped, it pushes another view controller. The problem is that I have another button of the same subclass on the newly presented view controller but when it appears it's cut off.
This problem solves itself when I tap a keyboard key and if I tap "Debug View Hierarchy" it appears fully drawn in Xcode and when I exit debugging it's fully drawn.
Here's an example of the problem in an iPhone XS Max iOS 12.1 and Swift 4.2 (I've covered with a red rectangle some text fields since they have user details but they're are subclasses of UITextField and the card view is a child view controller with a UICollectionView):
This is what I get
This is what I expect
I have tried putting setNeedsDisplay and layoutIfNeeded for the button and its superview inside viewDidAppear and viewWillAppear but I haven't been able to determine what's happening and how to solve it. I would really appreciate if someone could help me. Thank you!
I think this is not a rendering issue and its another view on top of the button. Try more investigating in view debugger
Then see what it is. (check other UIWindows)
I guess it's keyboard suggestion's view. or some footer view or etc.
It looks like the keyboard’s ´inputAccessoryView´ is getting in the way.
You can try disabling it.
Related
I got a funny question: "Can someone explain this behaviour?"
Click here to view .gif (I'm not allowed to post pictures yet)
Explanation: When I click on the search bar a new ViewController is being presented (the one you see in the gif). There the keyboard is immediately popping up. When I now dismiss the keyboard by scrolling down it seems like the cells that were behind the keyboard re-render or were not loaded yet... I have no clue where to search for this, so I spared the hassle of posting unnecessary code.
Thanks! :-)
Nothing is wrong with the gif. UITableView cells are created and reused when necessary. That is when they become visible or invisible. Since you changed the view controller with the keyboard popped up, only visible cells are created. The ones behind the keyboard are not initialized yet.
I am using IQKeyboardManager.
I am showing an UITextView in middle of the screen with transparent background when I click 'reply'. The entire viewController moving up, fine. but when I dismissed, the viewController top is under the statusBar.
why is it happening?
That is the behavior of IQKeyboardManager. IQKeyboardManager will take topmost view controller and based on the textView position it will push the whole view controller to up. There is nothing wrong with the library. That is how it's got implemented. So there are few ways to avoid this.
One way to use below line. Try once. I'm not sure this will work for every project.
self.view.window.windowLevel = UIWindowLevelStatusBar;
Another way is to add one more super view for TextView and try. These are few possible ways of handling it.
Try moving those TextFields inside a ScrollView and Navigation Bar (if using custom) out of ScrollView. It will solve this issue.
I have an iOS app that was created using storyboards with auto-layout. The View Controllers are in a navigation controller. Several steps down the navigation controller chain I have a button in VC1 that is connected to VC2 via a popover segue. When I tap the button, a popover view appears but is blank. I changed the background color of VC2 to see if the view was actually appearing. It was. No subviews were visible. I have created and recreated VC2. I have changed the sizes of the view, the subviews and the view controller. I have manually and automatically created restraints. I also created a test view controller outside of the navigation view controller. It behaved the same as the view controllers in the navigation controller.
Just to check if I was completely incompetent, I created a new project with a storyboard that had one VC. I placed a button in this VC with a popover segue to a second VC. It worked as desired. When the button was pressed a popover would appear and all subviews of the second VC would be visible. I tried placing the first VC in a navigation controller with no change. It continued to show the popover as it should. I have compared the two projects and I can't find what the problem is.
My question is this: Does anyone out there know of some hidden setting that would cause this behavior? or Any suggestions on what I'm missing here?
Well, after a whole lot of time (and even rewriting my project from scratch) I finally found the solution. Apparently, using size classes messes with popovers. To solve this solution, I turned size classes off completely. My app is iPad only so that worked for me. According to this thread: iOS8 Size-Classes and Popover Views you can also use the Any/Any size class. I was using Regular/Regular size class. I hope this helps someone.
Have a legacy UISplitViewController iPad app that displays a modal view from the "right side" VC pane using presentViewController:animated:completion: with the modalPresentationStyle set to UIModalPresentationFormSheet. In viewDidAppear of the modal view's VC, we call becomeFirstResponder on a UITextField. In iOS6, this results in a centered modal view sliding up from the bottom which then focuses the KB. However, since iOS7, what occurs is after the view slides up from the bottom, it slides to the right by about (estimating) 200 points. Weird thing is, if you dismiss the keyboard, as soon as you do, the view slides back to it's centered position like it is on iOS6. From then on, while the modal view is up, KB focus causes it to stay centered and only slide up a little, which is normal iOS behavior for non full screen modal views. It's like once you dismiss the KB once it "corrects" itself from then on. I have experimented and found that:
If you set animated to NO for the presentViewController call it works like iOS6.
If you don't call becomeFirstResponder at all, it works like iOS6.
If you call performSelector:xxxxafterDelay:0, passing becomeFirstResponder as the selector instead of calling becomeFirstResponder directly, it also works like iOS6.
Option 3 from above is currently my go forward workaround, but my question is: is this an iOS7 bug, or are we doing the wrong thing that was obviously ok in 6 but not in iOS7?
Only occurs post-iOS7. Only recreated once on simulator, but 100% of time on test device (iPad mini). From the searches I've done my current best guess (assuming our code isn't to blame post-iOS7) is there's a race condition type bug between the animations of the keyboard and the view sliding up from the bottom in the iOS UI layer that causes the view to shift right instead of up, like it normally does when a non full screen view is presented modally and the KB is popped. I got that theory after reading this similar SO question.
Had this problem. This is definitely a bug in iOS7.X. (You should open a bug report with Apple!). What happens is Apple has bug in its layout calculation and shifts the modally presented view.
We used
dispatch_async(dispatch_get_main_queue(), ^{ [view becomeFirstResponder]; });
to overcome the issue, which is similar to your #3. This delays the keyboard appearance until after the view's layout, overcoming the issue.
In XCode 5 storyboard (and maybe previous versions) I can drag a UIToolbar to the black area that shows underneath the view, so I have a view, first responder, toolbar and exit button.
But I can't seem to find any documentation that states the purpose of adding a toolbar there rather than in the view itself.
Does anyone know what this is for?
Thanks,
AJ
You can drag anything you like in there really, not just a toolbar.
The purpose is to have those objects instantiated along with the main view so that they are accessible from the ViewController (hook them up via IBOutlets).