I'm supporting both iOS 7 and iOS 8 in my app and using storyboard with autolayout to setup my views. I'm having an issue with iOS 7 only.
I have a subview which has a constraint that sets its top space to the bottom of the top layout guide. This makes sure that the subview does not go underneath the translucent navigation bar at the top. It works fine on iOS 8, however on iOS 7 the subview goes underneath the navigation bar right below the status bar.
Any advice on how I can make this work on iOS 7 as well?
Currently I'm using a hack to get this to work on iOS 7, which is below:
override func viewDidLayoutSubviews() {
if NSProcessInfo.instancesRespondToSelector(Selector("isOperatingSystemAtLeastVersion:")) {
// iOS 7 navBar hack
} else {
let navBarHeight = self.navigationController?.navigationBar.intrinsicContentSize().height
self.navHeightConstraint.constant = navBarHeight!
self.view.layoutSubviews()
}
}
Basically I connected the constraint through Interface Builder and I adjust it's constant to the height of the navigation bar if it's iOS 7. If anyone has a better way, please let me know.
Related
There was an issue in iOS 11 for UINavigationBar, when set topItem.prompt with code:self.navigationController.navigationBar.topItem.prompt = #"(1/5)" :
it works well on iOS 8~10, when it shows the prompt navigationBar will automatically changed height from default 44 to 74 (iPhone 5S);
while in iOS 11 the navigationBar height was still 44, thought the appearance was fine, the navigation button can't be clicked due to this height issue. Please see the snap image on iOS 8 and iOS 11:
Is there any way to fix this issue without using custom navigationBar?
I've fixed this issue by adding code [self.navigationController.navigationBar sizeToFit]; after setting the topItem.prompt.
Seems that there was an issue in iOS 11 that navigationBar couldn't change its height dynamicly. If the topItem.prompt was set before navigationBar shown, it didn't have this issue. But after shown, if we want to add an topItem.prompt, have to add the code. letting the navigationBar change to right height.
I recently migrated an App to Swift 4 and iOS 11 and noticed a very strange issue on iPads running iOS 10. When the UISearchController is presented, the UITableView gets a -20px offset making it partly covered by the search bar.
My view controller structure is UISplitViewController -> UINavigationController -> UIViewController. The UIViewController has only one view which is a UITableView. The UISearchController is added via code and the UISearchBar is added to the tableviews tableHeaderView.
On iPhone, its working perfectly fine and iOS 11 is also working like a charme. It's only happening on iOS 10 on iPad.
Try to set top space constraint to Top Layout Guide, not to superview.
Select Table View:
Size inspector, select Top constraint, double-click on it, change constraint item from Superview to Top Layout Guide.
We have custom tab bar in our app. The height of the custom tab bar is fixed. It was working fine for all devices except iPhone X. The problem is the height of custom tab bar is 45 but in iPhone X it will collide with the home indicator. So we had changed the bottom of the custom tab bar to the safe area. But the problem will be I will see the background view below my custom Tab bar. My question how can we give constraints to Custom tab bar that will be same height all devices except iPhone X and also hides the bottom space in iPhone X? but I want to increase the height of tab bar in iPhone X but I shouldn't affect other devices. Btw I don't want to write a code to separate iPhone X and other devices. All I want to do it in storyboard itself.
How about this?
set your view to be within safe area
set fixed height to your custom tab bar
put a view and set margin between safe area bottom and superview bottom
refer to the picture below
Constraints
How it looks like on iPhone X
How it looks like on other iPhone
How about making a view effect view at the bottom, which is larger than 44pt? I have tried it in my application and it works well.
refer: https://novemberfive.co/blog/apple-september-event-iphonex-apps/
Hope this helps you with programmatically
self.tabBar.layer.masksToBounds = true
self.tabBar.isTranslucent = true
self.tabBar.barStyle = .blackOpaque
self.tabBar.layer.cornerRadius = 20
self.tabBar.layer.maskedCorners = [.layerMinXMinYCorner, .layerMaxXMinYCorner]
I'm having issues to adopt RTL in my app that will be displayed well on both iOS 9 and 8.
I created a custom UITableViewCell with a UILabel as presented:
In both iOS 9 & 8, when I ran my in a RightToLeft language the labels aligns to the right as expected.
when i push a new ViewController with the navigationController the navigation direction of the UINavigaitonController is different in iOS9 & 8,
in iOS 9 the navigation direction is to the left:
and in iOS 8 the navigation direction is to the right:
I want that by Label on the Cell will be aligned according to the navigationController push animation direction.
so the result on iOS 8 will be as presented, but I still want to keep the respect language direction attribute in the constraint.
does any one knows how the resolve this issue?
Thanks!
One way to resolve it, is just to disable the RTL support, so on both RTL and LTR the result would be the same.
If you want to do it this way, do something like this:
if (SYSTEM_VERSION_GREATER_THAN_OR_EQUAL_TO(#"9.0")) {
[[UIView appearance] setSemanticContentAttribute:UISemanticContentAttributeForceLeftToRight];
}
I have an app that I want to upgrade to iOS 8, but since I found that status bar is being hidden on iPhone in landscape mode, I figured that I need to handle such a behaviour.
I solved this issue on iOS 7 by adding a constraint from the top of the navigation bar to the top of the view ( since I am not using Storyboards, some properties or features are not available through xib like top layout guide ) and used this method:
(UIBarPosition)positionForBar:(id<UIBarPositioning>)bar
{
return UIBarPositionTopAttached;
}
and it was working like charm, but on iOS 8 when status bar is hidden on landscape, navigation bar appears much taller that it is supposed to be. I may handle through constraints and use rotating events, but I believe there must be better ways to handle it.