如何使用 swift 在 ios 的滚动视图下滚动特定视图?

How to scroll particular views under the scrollview in ios using swift?

我有以下视图 75% 的视图是滚动视图,25% 的视图是底部图像视图。

childView 在 scrollviews 里面

我的屏幕UI

我也试过下面的代码但没有用

  @IBOutlet weak var Scrollview: UIScrollView!

  override func viewDidLoad() {
        super.viewDidLoad()

    Scrollview.contentSize.height = 1000

  }

Now when keyboard is open I am not able to click Create Button..I want to make scroll child view only under the Scrollview..I want to keep my Image in the Bottom fixed.Android I have done..please anyone help me I am new to iOS...

试试下面这个库,它一定会解决你的问题

https://github.com/michaeltyson/TPKeyboardAvoiding

您可以利用 NotificationCenter 在键盘打开时接收通知。 将此代码添加到您的 viewDidLoad() 方法中:

NotificationCenter.default.addObserver(forName: NSNotification.Name.UIKeyboardWillShow, object: nil, queue: nil) { (notification) in
    let keyboardHeight = (notification.userInfo?[UIKeyboardFrameEndUserInfoKey] as? NSValue)?.cgRectValue.height ?? 0.0

    Scrollview.contentInset = UIEdgeInsets(top: 0.0, left: 0.0, bottom: keyboardHeight, right: 0.0)
}


现在您应该可以滚动直到看到 Create Button.

注意: 您必须调整键盘高度值才能将正确的插图添加到您的 Scrollview(在您的情况下减去 imageView 键盘高度值的高度)。否则,您将在滚动视图中添加过多的插图。