IQKeyboardManager issue , UIViewController top overlapping status bar - ios

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.

Related

iOS Button not fully rendered after push transition

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.

The last Row of TableView in a ContainerView is Hidden Behind TabBar

Building an app that has tabbar. One of the tab, I need to use container view because I'm switching between three table view. That switching works well, so I will not show you those code to be clear. However, those tables are hidden behind tabbar. Like:
I'm using storyboard and the container view is such that:
So here I put intentionally container to the top of tabbar, because I don't want overlapping. Then with using these codes, I thought that would help me to find the bound of container and set it to the tableView:
The code line vc.view.frame = self.contentView.bounds; is what I'm telling. But that doesn't work at all, clearly, since table is still behind the tabbar.
There are solutions I found on internet, such as setting consentInsent of tableView in viewDidLoad, unchecking some properties of tabbar and making tabbar opaque. None of those worked. The reason I'm asking it this basically. I had to because I can't find a solution worked for my case.
Hope you can see the problem and help me to figure it out.
Please ask me if you need more information / explanation.
Any suggestions would be appreciated.
Thanks!
Try unchecking the under bottom bar property of the view controller from storyboard. If it doesn't work also uncheck the Adjust ScrollView Inset property over there.
Also you must be sure that bottom Layout constraint must be set to Bottom Layout Guide instead of superview.
where tab bar is not show set constraint as follows
Please try to set constraint like this, I hope it will help you.
I had a similar problem but without a table view and with Swift. Anyway my view got hidden behind my tab bar.
if let tabBarController = tabBarController {
tabBarController.tabBar.isTranslucent = false
}
Using this in my UIViewController which is shown by the UITabBarController solved the issue for me. I had the same problem with the navigation bar which is why I found the answer here but it also worked for the tab bar.

iOS : Swipe Gesture Push in one ViewController?

I want to add two swipe gesture. I did the code, and it's running, my text in the viewcontroller change when i touch the screen.
BUT, i want to add a "effect" when the user wants to slide at the next (or the previous) news, because currently, i'm just changing the text.
i tried to add action in the storyboard, to add push on the swipe with the view.
It's running, but there are two problems :
The push, seems to have a problem, because, when i want to slide on the previous news, the push effect comes right to left. (and not left - right)
I can't only change the contents without touch the navigation bar ? (because when i slide, the navigation bar loose him title, etc..)
If I understood you correctly you might want to use a UIScrollView. This will give you a nice animation.
You need a UIScrollView and add two of your ViewControllers as subviews.
Here are links to some ScollView tutorials:
Are there any good UIScrollView Tutorials on the net?
Pushing on the navigation controller stack is to the right if you want to go back to opposite direction instead of pushing, you should pop like so: [self.navigationController popViewControllerAnimated:YES]; You could paste some code in your question :)

presentViewController with custom transition

I would like to present a modal UIViewController with a different transitions to the ones available by the toolkit. Precisely I'd like an inverted animation compared to the slide from the bottom (UIModalTransitionStyleCoverVertical), present = slide in from the top, dismiss = slide out from the top.
I don't think there is a simply option for UIModalTransitionStyleCoverVertical to be inverted, so I guess I need to make one on my own.
I am also not using segue/storyboard either, not sure if this makes a difference.
I found some solutions which suggest to simply animate the new viewcontroller view and use presentViewController with the animated option as NO. Unfortunately the problem I have is that the background turns black straight away, even If I define the new viewcontroller view with clear background and not opaque.
Any idea how I could sort this out? Thanks a lot!
I solved the not transparent background issue taking a screenshot and using it as background for the modal view controller.
Apply your custom animation with CATransition.
Set modalPresentationStyle property for the presented view controller to UIModalPresentationCustom (available for iOS 7 or later). See also UIModalPresentationOverCurrentContext iOS8, or UIModalPresentationCurrentContext.
For my case I wanted to the same animation style, but I only needed to use UIModalPresentationOverCurrentContext for iOS 8.

Adding a toolbar to a navigation controller

I am completely new to ios development and I am only interested in developing for ios5.
I have an app with some scenes, they are mostly tableviews. I also use a navigation controller
I however need to add some status text and buttons that are always visible in all scenes and thought that a toolbar added to the navigation controller should do the trick.
so i thought that i should only have to drag out a toolbar in storyboard to the navigation controller, but it does not stick there. I can add it to the bar underneath with first responder and navigation controller but that does not help me (small icons).
I can also not add it to my table view (but if i drag out a plain view I can add it there)
do I have to make my own custom navigation class that the navigate view uses and then programatically add my toolbar?
Had the same question recently. Check Attributes Inspector in your ViewController's properties in storyboard. There you can define a Bottom Bar.
Well, inside the UINavigationController, you should have something... A UIViewController for instance. You can easily add a UIToolBar by dragging the object inside the UIView of the UIViewController. What might being happening is that as the root view you have the UITableView, in that case I think you can't do that. But to better understand, just take a small print screen of your StoryBoard.
If you zoom up to 100% on the storyboard it should drag.

Resources