简体   繁体   English

尝试在我的应用程序中使用TPKeyboardAvoding Scroll

[英]Trying to use TPKeyboardAvoding Scroll in my App

I'm using TPKeyBoardAvoidingScrollView in my iPhone App so that the scroll view scrolls while it reaches the end of the keyboard. 我在iPhone应用程序中使用TPKeyBoardAvoidingScrollView ,以便滚动视图在到达键盘末端时滚动。

By looking at the github readme, it said that I just have to drag and drop the TPKeyboardAvoidingScrollView into my project and assign the class of a ScrollView to it. 通过查看github自述文件,它说我只需要将TPKeyboardAvoidingScrollView到我的项目中并为其分配ScrollView的类。 I tried it, but it doesn't behave the way it is supposed to (nothing different happens). 我尝试过,但是它并没有按照预期的方式运行(没有发生任何不同的事情)。

This is my view hierarchy, is there anything wrong with it? 这是我的视图层次结构,这有什么问题吗?

  • View Hierarchy 查看层次结构

在此处输入图片说明

  • Embedded in ScrollVIew 嵌入ScrollVIew

在此处输入图片说明

Step 1: 第1步:

  • Delete your scrollview 删除滚动视图

Step 2: 第2步:

  • Select all you components that you want to put inside a scrollview, then go to Editor -> Embbed In -> Scroll View . 选择要放入Editor -> Embbed In -> Scroll View所有组件,然后转到Editor -> Embbed In -> Scroll View Now you will see a UIScrolView in your view hierarchy. 现在,您将在视图层次结构中看到一个UIScrolView

Step 3: 第三步:

  • Now select your UIScrollView go to the Identity Inspector and change the class UIScrollView to TPKeyboardAvodingScrollView 现在选择您的UIScrollView转到Identity Inspector并将UIScrollView类更改为TPKeyboardAvodingScrollView

Check the Sample 检查样品

For some reason it seems like TPKeyboardAvoidingScrollView doesnt get activated until the keyboard pops up. 由于某种原因,直到键盘弹出后,TPKeyboardAvoidingScrollView才被激活。 What worked for me were the following steps 对我有用的是以下步骤

  1. Reset your simulator so that they iPhone keyboard will pop up again (it doesn't show after you use your mac keyboard) 重置您的模拟器,以便它们的iPhone键盘再次弹出(使用Mac键盘后,它不会显示)
  2. Run the app again and click on a UITextView that is within the UIScrollview you created with TPKeyboardAvoidingScrollView 再次运行该应用程序,然后单击使用TPKeyboardAvoidingScrollView创建的UIScrollview中的UITextView

Now it should scroll 现在它应该滚动

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM