我正在尝试使用iOS 8.3模拟器在Xcode 10上使用Deployment Target iOS 8.0编译应用程序。
我已经从情节提要中禁用了《安全区域布局指南》,但是问题仍然存在。
你知道如何帮助我吗?
我们有一些旧项目仍在使用“自动调整大小”蒙版,并且在iOS 11和iPhone X之前一切正常。通过引入安全区域布局指南,支持iPhone X的最佳解决方案是什么?
我们可以使用自动调整大小的掩码将所有接口转换为使用自动布局。考虑到正在动态添加和调整视图,这似乎是一项巨大的工作。
我们继续使用自动调整大小的蒙版,但会调整界面以增加iPhone X和iOS 11的插入边距。
如果我覆盖了UIViewController的 funcviewSafeAreaInsetsDidChange是否需要调用 super?
override func viewSafeAreaInsetsDidChange() {
super.viewSafeAreaInsetsDidChange()
// do my stuff
}
Run Code Online (Sandbox Code Playgroud)
我知道,如果您覆盖func viewWillAppear(_ animated: Bool)并且没有调用super内部,您的应用程序可能会运行不正常。苹果实际上说你必须super在某个时候打电话。我想这不是这里的情况,这就是我想要确认的!
我在大多数应用程序中使用XIB而不是Storyboard.从图片中可以看出,我启用了安全区域布局指南以及自动布局,但出于某种原因,我的XIB仍然显示顶部和底部布局指南而不是安全区域.我错过了什么?好的,我更改了更新推荐的设置.它仍然没有在XIB文件中显示安全区域,但应用程序本身似乎确实尊重安全区域.这是否应该以正确的方式完成?
我有一个 viewController 持有这样的约束:
self.subviewConstraint = NSLayoutConstraint(item: self.subviewConstraint,
attribute: .bottom,
relatedBy: .equal,
toItem: self.bottomLayoutGuide,
attribute: .bottom,
multiplier: 1,
constant: 0)
Run Code Online (Sandbox Code Playgroud)
我收到以下警告:
iOS 11.0 中已弃用“bottomLayoutGuide”:使用 view.safeAreaLayoutGuide.bottomAnchor 而不是 BottomLayoutGuide.topAnchor
我只是找到设置锚点而不是像NSLayoutConstraint这样的 s 的示例,并且我不完全理解此警告...“使用 view.safeAreaLayoutGuide.bottomAnchor而不是 BottomLayoutGuide.topAnchor ”?safeAreaLayoutGuide的底部锚点与顶部锚点如何匹配bottomLayoutGuide?我在哪里可以找到对此的良好图形解释?我应该如何正确地重写我的约束以保持其当前的行为?
我希望导航栏扩展到以编程方式创建的 UINavigationController 中的安全区域。我正在开发一个项目,他们以编程方式创建初始视图控制器并在 SceneDelegate 中设置其导航栏:
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
let initialViewController = initViewController()
let navigationCotnroller = UINavigationController(rootViewController: initialViewController)
navigationBarConfiguration(navigationCotnroller)
window?.rootViewController = navigationCotnroller
window?.makeKeyAndVisible()
}
private func initViewController () -> UIViewController {
let view_controller_to_be_returned = DeviceSearchVC()
view_controller_to_be_returned.title = "Devices"
return view_controller_to_be_returned
}
private func navigationBarConfiguration (_ controller: UINavigationController) {
controller.navigationBar.prefersLargeTitles = true
controller.navigationBar.largeTitleTextAttributes = [NSAttributedString.Key.foregroundColor: UIColor.white]
controller.navigationBar.titleTextAttributes = [NSAttributedString.Key.foregroundColor: …Run Code Online (Sandbox Code Playgroud) uinavigationcontroller navigationbar ios swift safearealayoutguide
以下是启用了安全区域布局指南的限于超级视图的顶部,左侧,右侧和底部的集合视图:
我希望我的收藏视图标题显示在状态栏下。对于iPhone 4-8+的屏幕尺寸,我已经实现了这一点,方法是取消选中控制器main的大小检查器中的“安全区域布局指南”view,并添加以下代码:
collectionView.contentInset = UIEdgeInsets(top: -20, left: 0, bottom: 0, right: 0)
Run Code Online (Sandbox Code Playgroud)
对于非iPhone X视图尺寸,这看起来很棒:
但是,对于iPhone X,这将导致以下输出:
iPhone X在状态栏上有其自己的尺寸。进一步调整顶部插图确实可以,但是会抵消其他设备的尺寸。我想知道是否有一种更优雅的方式来实现此行为。
我有一个关于iOS安全区域使用的问题。
我通过 a使用背景图像,并在此背景图像上RelativeLayout显示一个表单。我margin在表单的容器上使用了 iOS 版本:效果很好,但iPhone X上的渲染效果不太好。
<RelativeLayout>
<Image Source="background.jpg" Opacity="0.75"
Aspect="AspectFill"
RelativeLayout.WidthConstraint =
"{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint =
"{ConstraintExpression Type=RelativeToParent, Property=Height}" />
<ScrollView RelativeLayout.WidthConstraint =
"{ConstraintExpression Type=RelativeToParent, Property=Width}"
RelativeLayout.HeightConstraint =
"{ConstraintExpression Type=RelativeToParent, Property=Height}">
<ScrollView.Margin>
<OnPlatform x:TypeArguments="Thickness">
<On Platform="iOS" Value="0, 20, 0, 0" />
</OnPlatform>
</ScrollView.Margin>
<StackLayout>
<!-- Header -->
<StackLayout VerticalOptions="Start">
<fnc:HunterHeader />
</StackLayout>
<!-- Form -->
<StackLayout VerticalOptions="CenterAndExpand"
Spacing="6" Margin="20">
<!-- ... -->
</StackLayout>
</StackLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
所以我尝试将 …
iphone background-image ios xamarin.forms safearealayoutguide
我UITableView里面很简单UIViewController。这是我设置的配置和约束:
tableView.translatesAutoresizingMaskIntoConstraints = false
tableView.insetsContentViewsToSafeArea = false
view.addSubview(tableView)
tableView.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
tableView.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
tableView.topAnchor.constraint(equalTo: view.topAnchor).isActive = true
tableView.bottomAnchor.constraint(equalTo: view.bottomAnchor).isActive = true
Run Code Online (Sandbox Code Playgroud)
通过这样做,我取消了 UITableView 中的 safeArea 并设置顶部、底部约束忽略safeAreaLayoutGuide。是的,当我滚动表格时它完美地工作,并且安全区域根据我的需要被忽略。这是显示此内容的图像:
但问题是在一开始我不开始滚动或触摸桌子时。它从安全区域以下开始,而不是在安全区域之外。这里是:
我不希望这样的事情发生。我希望我的UITableView(或第一个UITableViewCell)从最高点忽略安全区域。UITableView即使我正确设置约束,它似乎也会忽略这一点。那么,如何解决这个问题呢?
ios ×10
ios11 ×4
autolayout ×2
iphone-x ×2
swift ×2
xcode ×2
iphone ×1
layout ×1
storyboard ×1
uitableview ×1