- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我遇到一个问题,我可以在 UIViewController
中看到黑色部分,其中有 UISearchController
、UICollectionView
和 UISegmentControl
因为我的设计很糟糕。
我使用以下代码在 navigationbar
中添加了 UISearchController
:
func setupSearchBar(){
navigationItem.searchController = taskSearchController
taskSearchController.searchBar.tintColor = .white
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).defaultTextAttributes = [NSAttributedStringKey.foregroundColor.rawValue: UIColor.lightGray]
UITextField.appearance(whenContainedInInstancesOf: [UISearchBar.self]).attributedPlaceholder = NSAttributedString(string: "Search Text", attributes: [NSAttributedStringKey.foregroundColor: UIColor.lightGray])
if let textfield = taskSearchController.searchBar.value(forKey: "searchField") as? UITextField {
if let backgroundview = textfield.subviews.first {
backgroundview.backgroundColor = UIColor.init(white: 1, alpha: 1)
backgroundview.layer.cornerRadius = 10
backgroundview.clipsToBounds = true
}
}
taskSearchController.hidesNavigationBarDuringPresentation = true
//navigationItem.hidesSearchBarWhenScrolling = false
//taskSearchController.searchBar.scopeButtonTitles = ["ASSIGNED TASK","CREATED TASK"]
}
添加UISearchController
后,我使用以下代码添加UISegmentControl
和UICollectionView
:
func setupView(){
//self.view.addSubview(coverView)
self.view.addSubview(taskSegment)
taskSegment.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor).isActive = true
taskSegment.leadingAnchor.constraint(equalTo: view.leadingAnchor).isActive = true
taskSegment.trailingAnchor.constraint(equalTo: view.trailingAnchor).isActive = true
taskSegment.heightAnchor.constraint(equalToConstant: 30).isActive = true
self.view.addSubview(collectionView)
collectionView.leadingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.leadingAnchor).isActive = true
collectionView.trailingAnchor.constraint(equalTo: view.safeAreaLayoutGuide.trailingAnchor).isActive = true
collectionView.topAnchor.constraint(equalTo: taskSegment.bottomAnchor, constant: 10).isActive = true
collectionView.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor, constant: 5).isActive = true
}
在这里你可以看到当 navigationBar
隐藏并且 UISearchController
放置在顶部时,我的 UISegment
和 UIcollectionView
保持在相同的位置,因此我想根据 UISearchController
中的更改移动它。
谁能告诉我我该怎么办?
提前谢谢您。
最佳答案
它隐藏了导航栏,因为 hideNavigationBarDuringPresentation设置为 true。这是预期的行为。
您要么需要禁用此功能,以便 View 约束在演示过程中不会发生变化,要么需要修改约束,以便 View 能够适应导航栏的高度变化。通过为主视图的安全区域设置顶部约束,您应该能够很容易地做到这一点。
关于swift - 当 UISearchController 聚焦时重置 UIView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51131678/
我正在使用 Json 数据创建 ListView 。我正在填充一些图像、文本字段和一个按钮。当用户单击按钮时,按钮标题会发生变化。 问题是如果按钮被修改并且用户滚动 ListView 按钮重置为第一个
在我的 iOS 测验应用程序中,您有 15 秒的时间来回答问题。如果回答正确,则会出现第二个 View Controller ,然后单击第二个 View Controller 上的按钮将其关闭,并且第
我现在使用 Objective-C 在 iOS 中实现一个功能,即当 slider 值发生变化时,在 slider 的“节点”上方制作一个文本标签。文本标签文本是 slider 的当前值。 因此,我在
所以我有一个名为 AuthStack 的堆栈像这样 const AuthStack = ({ resetPassword, updateEmail }: any) => (
在我的 Flutter 小部件中,我有一个 StreamBuilder检查 snapshot.hasError在这种特定情况下,它将返回我的 ErrorRetryWidget() . builder:
如果我的手机 hibernate 或我离开应用程序发送短信/接听电话,我的应用程序将重新启动。我该如何防止这种情况? 我希望保存对象而不是基本数据类型。如果应用程序关闭或手机关闭,我不需要保存应用程序
我有一个如下所示的数据框: ID TIME AMT 1 0 50 1 1 0 1 2 0 1 3 0 1 4 0 1 4 5
我正在使用 org.eclipse.swt.widgets.Combo 类,我正在执行以下操作 Combo myCombo = new Combo(container, SWT.READ_ONLY);
我有一个 UISWitch 默认位置设置为 off 用户可选择将开关设置为on,我如何通过另一个按钮/操作将该开关重新关闭。 - (IBAction)switchToggled:(id)sender
我试图让玩家 Sprite 节点在接触到危险节点时重置。我怎样才能做到这一点?该代码不起作用。 if player.position == danger.position { player.p
我尝试在启动 UITests 时重置和恢复 UserDefaults 并在它们分别完成时恢复它们。这是在 AppDelegate 中使用的代码: func makeDefaultsBackup() {
我有一个公用事业账单分段表,其中每个分段表示一个月的千瓦时使用情况。我想将 12 人一组合计起来以获得年度账单。 变量bill_cd表示年度账单的最后一部分。 Data download cu
我刚刚使用 composer 为项目安装了一些依赖项。在这个项目中,我们使用 cartalyst/sentry-social 包。为此,我必须使用一个特殊的 GitHub 帐户——但我不知道我在使用该
我对 Marionette collectionView 有疑问。当我没有定义 el 时 var featureditems = new View.CarouselItems({ collection
我有一个knockout/mvc3应用程序。我正在将日期传递回 Controller 。 Controller public ActionResult PackageUpdate(Package up
我有 2 个 Activity ,在第二个 Activity 中,我阅读并对本地 JSON 文件进行了一些更改,它适用于我需要的所有内容,但是当我转到 mainActivity 然后返回到第二个 Ac
我有一个带有 .xib 的 UIViewController,它有 2 个名为“LblA”和“LblB”的 UILable。让我们将此 ViewController 称为“A”。 LblA 和 Lbl
该模型将 LSTM 作为其第一层。 在调用 model.predict 时说你传入了几个样本: >sam = np.array([ [[.5, .6, .3]], [[.6, .6, .3]], [[
我开始使用 Angular.JS。 我有许多共享同一个 Controller 的 View 。每个 View 都是收集存储在 Controller 中的数据的一个步骤: $routeProvider.
我已经使用 DDEV 几天了,它很棒。 但是我发现如果我运行 ddev ssh通过 ssh 进入容器,并通过 npm / aptitude 安装包等等,或者如果我在 ~/ 中创建新文件主目录,有时这些
我是一名优秀的程序员,十分优秀!