用于键盘输入的简单 UIToolarAccessoryView 的布局约束错误

2024-03-13

我遇到了很多布局约束错误,因此我创建了一个新项目,并仅使用 UIToolbar 和 UITextField 来尝试解决问题。即使有一个干净的项目,即使我没有覆盖任何限制,我仍然会遇到奇怪的错误.inputAccessoryView.

代码如下(无故事板内容):

import UIKit

class ViewController: UIViewController {

    var aTextField = UITextField()

    override func viewDidLoad() {
        super.viewDidLoad()

        let aKeyboardToolBar = UIToolbar()

        // add buttons to the toolbar
        let prevButton = UIBarButtonItem(title: "PREV", style: .done, target: self, action: #selector(prevButtonTapped))
        let nextButton = UIBarButtonItem(title: "NEXT", style: .done, target: self, action: #selector(nextButtonTapped))
        let doneButton = UIBarButtonItem(title: "DONE", style: .done, target: self, action: #selector(doneButtonTapped))
        let flexibleSpace = UIBarButtonItem(barButtonSystemItem: .flexibleSpace, target: self, action: nil)

        aKeyboardToolBar.setItems([prevButton, nextButton, flexibleSpace, doneButton], animated: true)
        aKeyboardToolBar.sizeToFit()

        // Add first textfield
        view.addSubview(aTextField)
        aTextField.backgroundColor = .orange
        aTextField.placeholder = "Blank TextField"
        aTextField.inputAccessoryView = aKeyboardToolBar

        // Layout first text field
        aTextField.translatesAutoresizingMaskIntoConstraints = false
        aTextField.topAnchor.constraint(equalTo: view.topAnchor, constant: 150).isActive = true
        aTextField.leftAnchor.constraint(equalTo: view.leftAnchor, constant: 20).isActive = true
        aTextField.rightAnchor.constraint(equalTo: view.rightAnchor, constant: -20).isActive = true
    }



    @objc func prevButtonTapped() {
        print("prevButtonTapped")
    }



    @objc func nextButtonTapped() {
        print("nextButtonTapped")
    }



    @objc func doneButtonTapped() {
        view.endEditing(true)
    }

}

错误(KeyboardShifter 是项目的名称):

2020-01-12 11:41:16.300180+1100 KeyboardShifter[1304:1170583] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x283f240a0 h=--& v=--& _UIToolbarContentView:0x10125fed0.width == 0   (active)>",
    "<NSLayoutConstraint:0x283f45d60 H:|-(0)-[_UIButtonBarStackView:0x10120fba0]   (active, names: '|':_UIToolbarContentView:0x10125fed0 )>",
    "<NSLayoutConstraint:0x283f45db0 _UIButtonBarStackView:0x10120fba0.trailing == _UIToolbarContentView:0x10125fed0.trailing   (active)>",
    "<NSLayoutConstraint:0x283f2ab70 'TB_Leading_Leading' H:|-(8)-[_UIModernBarButton:0x1011645b0'NEXT']   (active, names: '|':_UIButtonBarButton:0x1011641d0 )>",
    "<NSLayoutConstraint:0x283f2abc0 'TB_Trailing_Trailing' H:[_UIModernBarButton:0x1011645b0'NEXT']-(8)-|   (active, names: '|':_UIButtonBarButton:0x1011641d0 )>",
    "<NSLayoutConstraint:0x283f2b5c0 'UISV-canvas-connection' UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x10115d760.leading   (active)>",
    "<NSLayoutConstraint:0x283f2b610 'UISV-canvas-connection' UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.trailing == _UIButtonBarButton:0x1011650e0.trailing   (active)>",
    "<NSLayoutConstraint:0x283f2b840 'UISV-spacing' H:[_UIButtonBarButton:0x10115d760]-(0)-[UIView:0x101164060]   (active)>",
    "<NSLayoutConstraint:0x283f2b890 'UISV-spacing' H:[UIView:0x101164060]-(0)-[_UIButtonBarButton:0x1011641d0]   (active)>",
    "<NSLayoutConstraint:0x283f2b8e0 'UISV-spacing' H:[_UIButtonBarButton:0x1011641d0]-(0)-[UIView:0x101164f70]   (active)>",
    "<NSLayoutConstraint:0x283f2b930 'UISV-spacing' H:[UIView:0x101164f70]-(0)-[_UIButtonBarButton:0x1011650e0]   (active)>",
    "<NSLayoutConstraint:0x283f45bd0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>",
    "<NSLayoutConstraint:0x283f45c70 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']-(0)-|(LTR)   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283f2abc0 'TB_Trailing_Trailing' H:[_UIModernBarButton:0x1011645b0'NEXT']-(8)-|   (active, names: '|':_UIButtonBarButton:0x1011641d0 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-01-12 11:41:16.301336+1100 KeyboardShifter[1304:1170583] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x283f240a0 h=--& v=--& _UIToolbarContentView:0x10125fed0.width == 0   (active)>",
    "<NSLayoutConstraint:0x283f45d60 H:|-(0)-[_UIButtonBarStackView:0x10120fba0]   (active, names: '|':_UIToolbarContentView:0x10125fed0 )>",
    "<NSLayoutConstraint:0x283f45db0 _UIButtonBarStackView:0x10120fba0.trailing == _UIToolbarContentView:0x10125fed0.trailing   (active)>",
    "<NSLayoutConstraint:0x283f2a490 'TB_Leading_Leading' H:|-(0)-[_UIModernBarButton:0x10115e6d0'PREV']   (active, names: '|':_UIButtonBarButton:0x10115d760 )>",
    "<NSLayoutConstraint:0x283f2a4e0 'TB_Trailing_Trailing' H:[_UIModernBarButton:0x10115e6d0'PREV']-(8)-|   (active, names: '|':_UIButtonBarButton:0x10115d760 )>",
    "<NSLayoutConstraint:0x283f2b5c0 'UISV-canvas-connection' UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x10115d760.leading   (active)>",
    "<NSLayoutConstraint:0x283f2b610 'UISV-canvas-connection' UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.trailing == _UIButtonBarButton:0x1011650e0.trailing   (active)>",
    "<NSLayoutConstraint:0x283f2b840 'UISV-spacing' H:[_UIButtonBarButton:0x10115d760]-(0)-[UIView:0x101164060]   (active)>",
    "<NSLayoutConstraint:0x283f2b890 'UISV-spacing' H:[UIView:0x101164060]-(0)-[_UIButtonBarButton:0x1011641d0]   (active)>",
    "<NSLayoutConstraint:0x283f2b8e0 'UISV-spacing' H:[_UIButtonBarButton:0x1011641d0]-(0)-[UIView:0x101164f70]   (active)>",
    "<NSLayoutConstraint:0x283f2b930 'UISV-spacing' H:[UIView:0x101164f70]-(0)-[_UIButtonBarButton:0x1011650e0]   (active)>",
    "<NSLayoutConstraint:0x283f45bd0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>",
    "<NSLayoutConstraint:0x283f45c70 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']-(0)-|(LTR)   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283f2a4e0 'TB_Trailing_Trailing' H:[_UIModernBarButton:0x10115e6d0'PREV']-(8)-|   (active, names: '|':_UIButtonBarButton:0x10115d760 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-01-12 11:41:16.302024+1100 KeyboardShifter[1304:1170583] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x283f240a0 h=--& v=--& _UIToolbarContentView:0x10125fed0.width == 0   (active)>",
    "<NSLayoutConstraint:0x283f45d60 H:|-(0)-[_UIButtonBarStackView:0x10120fba0]   (active, names: '|':_UIToolbarContentView:0x10125fed0 )>",
    "<NSLayoutConstraint:0x283f45db0 _UIButtonBarStackView:0x10120fba0.trailing == _UIToolbarContentView:0x10125fed0.trailing   (active)>",
    "<NSLayoutConstraint:0x283f2b200 'TB_Leading_Leading' H:|-(8)-[_UIModernBarButton:0x1011652c0'DONE']   (active, names: '|':_UIButtonBarButton:0x1011650e0 )>",
    "<NSLayoutConstraint:0x283f2b250 'TB_Trailing_Trailing' H:[_UIModernBarButton:0x1011652c0'DONE']-(0)-|   (active, names: '|':_UIButtonBarButton:0x1011650e0 )>",
    "<NSLayoutConstraint:0x283f2b5c0 'UISV-canvas-connection' UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.leading == _UIButtonBarButton:0x10115d760.leading   (active)>",
    "<NSLayoutConstraint:0x283f2b610 'UISV-canvas-connection' UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.trailing == _UIButtonBarButton:0x1011650e0.trailing   (active)>",
    "<NSLayoutConstraint:0x283f2b840 'UISV-spacing' H:[_UIButtonBarButton:0x10115d760]-(0)-[UIView:0x101164060]   (active)>",
    "<NSLayoutConstraint:0x283f2b890 'UISV-spacing' H:[UIView:0x101164060]-(0)-[_UIButtonBarButton:0x1011641d0]   (active)>",
    "<NSLayoutConstraint:0x283f2b8e0 'UISV-spacing' H:[_UIButtonBarButton:0x1011641d0]-(0)-[UIView:0x101164f70]   (active)>",
    "<NSLayoutConstraint:0x283f2b930 'UISV-spacing' H:[UIView:0x101164f70]-(0)-[_UIButtonBarButton:0x1011650e0]   (active)>",
    "<NSLayoutConstraint:0x283f45bd0 'UIView-leftMargin-guide-constraint' H:|-(0)-[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'](LTR)   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>",
    "<NSLayoutConstraint:0x283f45c70 'UIView-rightMargin-guide-constraint' H:[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']-(0)-|(LTR)   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283f2b250 'TB_Trailing_Trailing' H:[_UIModernBarButton:0x1011652c0'DONE']-(0)-|   (active, names: '|':_UIButtonBarButton:0x1011650e0 )>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-01-12 11:41:16.302742+1100 KeyboardShifter[1304:1170583] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x283f24140 h=--& v=--& _UIToolbarContentView:0x10125fed0.height == 0   (active)>",
    "<NSLayoutConstraint:0x283f45e00 V:|-(0)-[_UIButtonBarStackView:0x10120fba0]   (active, names: '|':_UIToolbarContentView:0x10125fed0 )>",
    "<NSLayoutConstraint:0x283f45e50 _UIButtonBarStackView:0x10120fba0.bottom == _UIToolbarContentView:0x10125fed0.bottom   (active)>",
    "<NSLayoutConstraint:0x283f250e0 UIButtonLabel:0x101163420'PREV'.centerY == _UIModernBarButton:0x10115e6d0'PREV'.centerY + 1.5   (active)>",
    "<NSLayoutConstraint:0x283f2a670 'TB_Baseline_Baseline' _UIModernBarButton:0x10115e6d0'PREV'.lastBaseline == UILayoutGuide:0x28257c620'UIViewLayoutMarginsGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x283f2a6c0 'TB_Top_Top' V:|-(>=0)-[_UIModernBarButton:0x10115e6d0'PREV']   (active, names: '|':_UIButtonBarButton:0x10115d760 )>",
    "<NSLayoutConstraint:0x283f2a800 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x10115d760.height == UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.height   (active)>",
    "<NSLayoutConstraint:0x283f45c20 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']-(0)-|   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>",
    "<NSLayoutConstraint:0x283f2a5d0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x28257c620'UIViewLayoutMarginsGuide']-(11)-|   (active, names: '|':_UIButtonBarButton:0x10115d760 )>",
    "<NSLayoutConstraint:0x283f45b80 'UIView-topMargin-guide-constraint' V:|-(0)-[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283f250e0 UIButtonLabel:0x101163420'PREV'.centerY == _UIModernBarButton:0x10115e6d0'PREV'.centerY + 1.5   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-01-12 11:41:16.303504+1100 KeyboardShifter[1304:1170583] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x283f24140 h=--& v=--& _UIToolbarContentView:0x10125fed0.height == 0   (active)>",
    "<NSLayoutConstraint:0x283f45e00 V:|-(0)-[_UIButtonBarStackView:0x10120fba0]   (active, names: '|':_UIToolbarContentView:0x10125fed0 )>",
    "<NSLayoutConstraint:0x283f45e50 _UIButtonBarStackView:0x10120fba0.bottom == _UIToolbarContentView:0x10125fed0.bottom   (active)>",
    "<NSLayoutConstraint:0x283f25810 UIButtonLabel:0x101164880'NEXT'.centerY == _UIModernBarButton:0x1011645b0'NEXT'.centerY + 1.5   (active)>",
    "<NSLayoutConstraint:0x283f2ad50 'TB_Baseline_Baseline' _UIModernBarButton:0x1011645b0'NEXT'.lastBaseline == UILayoutGuide:0x28257c700'UIViewLayoutMarginsGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x283f2ada0 'TB_Top_Top' V:|-(>=0)-[_UIModernBarButton:0x1011645b0'NEXT']   (active, names: '|':_UIButtonBarButton:0x1011641d0 )>",
    "<NSLayoutConstraint:0x283f2aee0 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x1011641d0.height == UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.height   (active)>",
    "<NSLayoutConstraint:0x283f45c20 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']-(0)-|   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>",
    "<NSLayoutConstraint:0x283f2acb0 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x28257c700'UIViewLayoutMarginsGuide']-(11)-|   (active, names: '|':_UIButtonBarButton:0x1011641d0 )>",
    "<NSLayoutConstraint:0x283f45b80 'UIView-topMargin-guide-constraint' V:|-(0)-[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283f25810 UIButtonLabel:0x101164880'NEXT'.centerY == _UIModernBarButton:0x1011645b0'NEXT'.centerY + 1.5   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.
2020-01-12 11:41:16.304192+1100 KeyboardShifter[1304:1170583] [LayoutConstraints] Unable to simultaneously satisfy constraints.
    Probably at least one of the constraints in the following list is one you don't want. 
    Try this: 
        (1) look at each constraint and try to figure out which you don't expect; 
        (2) find the code that added the unwanted constraint or constraints and fix it. 
    (Note: If you're seeing NSAutoresizingMaskLayoutConstraints that you don't understand, refer to the documentation for the UIView property translatesAutoresizingMaskIntoConstraints) 
(
    "<NSAutoresizingMaskLayoutConstraint:0x283f24140 h=--& v=--& _UIToolbarContentView:0x10125fed0.height == 0   (active)>",
    "<NSLayoutConstraint:0x283f45e00 V:|-(0)-[_UIButtonBarStackView:0x10120fba0]   (active, names: '|':_UIToolbarContentView:0x10125fed0 )>",
    "<NSLayoutConstraint:0x283f45e50 _UIButtonBarStackView:0x10120fba0.bottom == _UIToolbarContentView:0x10125fed0.bottom   (active)>",
    "<NSLayoutConstraint:0x283f25f40 UIButtonLabel:0x101165590'DONE'.centerY == _UIModernBarButton:0x1011652c0'DONE'.centerY + 1.5   (active)>",
    "<NSLayoutConstraint:0x283f2b3e0 'TB_Baseline_Baseline' _UIModernBarButton:0x1011652c0'DONE'.lastBaseline == UILayoutGuide:0x28257c7e0'UIViewLayoutMarginsGuide'.bottom   (active)>",
    "<NSLayoutConstraint:0x283f2b430 'TB_Top_Top' V:|-(>=0)-[_UIModernBarButton:0x1011652c0'DONE']   (active, names: '|':_UIButtonBarButton:0x1011650e0 )>",
    "<NSLayoutConstraint:0x283f2b570 'UIButtonBar.maximumAlignmentSize' _UIButtonBarButton:0x1011650e0.height == UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide'.height   (active)>",
    "<NSLayoutConstraint:0x283f45c20 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']-(0)-|   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>",
    "<NSLayoutConstraint:0x283f2b340 'UIView-bottomMargin-guide-constraint' V:[UILayoutGuide:0x28257c7e0'UIViewLayoutMarginsGuide']-(11)-|   (active, names: '|':_UIButtonBarButton:0x1011650e0 )>",
    "<NSLayoutConstraint:0x283f45b80 'UIView-topMargin-guide-constraint' V:|-(0)-[UILayoutGuide:0x282568460'UIViewLayoutMarginsGuide']   (active, names: '|':_UIButtonBarStackView:0x10120fba0 )>"
)

Will attempt to recover by breaking constraint 
<NSLayoutConstraint:0x283f25f40 UIButtonLabel:0x101165590'DONE'.centerY == _UIModernBarButton:0x1011652c0'DONE'.centerY + 1.5   (active)>

Make a symbolic breakpoint at UIViewAlertForUnsatisfiableConstraints to catch this in the debugger.
The methods in the UIConstraintBasedLayoutDebugging category on UIView listed in <UIKitCore/UIView.h> may also be helpful.

有任何想法吗?


Change

let aKeyboardToolBar = UIToolbar()

to

let aKeyboardToolBar = UIToolbar(frame:CGRect(x:0, y:0, width:100, height:100))

这样就有了some当您为其提供内容时要使用的大小。

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

用于键盘输入的简单 UIToolarAccessoryView 的布局约束错误 的相关文章

  • 在 Swift 中执行 POST 请求

    我正在尝试做这样的事情 NSMutableURLRequest request NSMutableURLRequest requestWithURL NSURL URLWithString http google com request H
  • 开始/停止图像视图旋转动画

    我有一个开始 停止按钮和一个我想要旋转的图像视图 当我按下按钮时 我希望图像开始旋转 当我再次按下按钮时 图像应该停止旋转 我目前正在使用UIView动画 但我还没有找到停止视图动画的方法 我希望图像旋转 但是当动画停止时 图像不应返回到起
  • 如何从 UIView 中仅删除用户添加的子视图

    我试图删除添加到视图中的所有子视图 因此我实现了一个循环来使用以下内容迭代子视图 for subview in view subviews println subview subview removeFromSuperview 我通过向我的
  • 如何在 Xcode 8.0 中安装 Alamofire 4.0

    我正在使用更新的 Xcode 8 0 如何使用 cocoa pod 安装 alamofire 4 0 我试过这个https github com Alamofire Alamofire https github com Alamofire
  • Swift UIPickerView 禁用组件

    I m having following UI 如果使用开关 是否可以仅禁用最后两个组件 如果是这样 我该怎么做 您无法禁用这些组件 不过您可以尝试这些解决方案 第一个解决方案 var selectedRow3 3 var selected
  • 如何使用 Swift 从资源中加载特定图像[重复]

    这个问题在这里已经有答案了 我是 Swift 新手 我想从资源中加载特殊图像 例如我有 image 1 for iphone 4s email protected cdn cgi l email protection image 2 for
  • SwiftUI 按钮在出现时更改文本大小

    从 GIF 中可以看出 一旦工作表完全打开 完成 按钮文本就会变大 这不仅发生在这个视图中 而且也发生在使用系统图像而不是文本的其他视图中 有谁知道问题的解决方案还是我做错了什么 我仍然对 Swift 记忆犹新 NavigationView
  • 带有图层圆角半径和阴影的 UILabel

    我正在寻找一种方式来显示UILabel with layer cornerRadius and layer shadow 我发现 与label clipsToBounds true the cornerRadius将被设置并与label m
  • 以编程方式设置 Swift 元素的位置

    我在故事板中定义了一个标签 我正在尝试以编程方式更改其位置 SO 上已有一些问题似乎可以解决此问题 但似乎没有一个解决方案有效 即标签不移动 我已经删除了标签上所有现有的限制 但无济于事 我试过了 class LandingViewCont
  • SceneDelegate 和 AppDelegate 之间的区别

    在我的 SwiftUI 项目中我看到AppDelegate文件以及SceneDelegate file 它们之间有什么区别 例如在方法之间SceneDelegate scene willConnectTo options 并在AppDele
  • 跨不同的 viewController 使用相同的 UIWebView

    TL DR 我需要实现一个在多个 ViewController 之间共享的单例 UIWebVIew 这个问题包含了我迄今为止的所有方法 应用程序委托 property strong nonatomic UIWebView singleWeb
  • Semaphore.wait(timeout: .now()) 的目的是什么?

    看了一些苹果代码示例 我发现了这一点 func metadataOutput output AVCaptureMetadataOutput didOutput metadataObjects AVMetadataObject from co
  • libicuuc.so.55:无法打开共享对象文件

    当我使用 swift build 进行编译时 我的 Ubuntu 机器上出现以下错误 swift build home xxxxxxxxx Downloads swift DEVELOPMENT SNAPSHOT 2016 02 25 a
  • 添加滑动删除UITableViewCell

    我正在制作一个清单应用程序UITableView 我想知道如何添加滑动删除UITableViewCell 这是我的 ViewController swift import UIKit class ViewController UIViewC
  • Swift(UI) 错误:无法在不可变值上使用变异成员:“self”是不可变的

    基本上我想做的是 如果您按下按钮 那么条目应该获得一个新的 CEntry 如果有人能帮助我那就太好了 谢谢 struct AView View var entries CEntries var body some View ZStack V
  • 使用新数据快速更新 UITableView

    我正在尝试重新填充我的UITableView来自另一个 JSON 调用的数据 然而 我当前的设置似乎不起作用 虽然有很多相同的问题 但我可以找到我已经尝试过的答案 我将 API 数据保存在CoreData实体对象 我用我的 UITableV
  • 如何在 UITabBarController 中显示 ViewController?

    我有一个 UITabBarController 所有其他视图控制器都连接到它 现在我想将我的控制器显示为 let storyboard UIStoryboard name Main bundle nil let vc ViewControl
  • 需要帮助设置两个宽度相等的并排自动布局按钮

    使用自动布局我尝试在底部创建两个按钮 如下所示 拖动两个按钮后 我设置这样的约束 On Back button I set Leading Space to Container Margin and Bottom Space to Bott
  • Swift:ViewModel 应该是结构体还是类?

    我正在尝试在我的新项目中使用 MVVM 模式 第一次 我创建了所有的视图模型来构建 但是 当我使用闭包实现异步业务逻辑 例如 fetchDataFromNetwork 时 闭包捕获旧视图模型值 然后更新为该值 不是新的视图模型值 这是操场上
  • 增加导航栏高度

    我有以下代码 func navbarbutton UIView animateWithDuration 0 2 animations gt Void in let current self navigationController navi

随机推荐