使用IQKeyBoardManger 键盘弹出时导航栏也移动的问题

解决方法:

在视图控制器里重写方法:

-(void)loadView
{
    UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    self.view = scrollView;
}

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
可以使用以下布局文件实现 PIN 码弹出键盘导航栏的距离: ```xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent"> <!-- 导航栏 --> <androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:layout_alignParentTop="true" android:background="?attr/colorPrimary" android:elevation="4dp" android:theme="@style/ThemeOverlay.AppCompat.ActionBar" /> <!-- PIN码弹出键盘 --> <LinearLayout android:id="@+id/pin_keyboard" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="@android:color/white" android:orientation="vertical" android:paddingBottom="16dp" android:paddingLeft="16dp" android:paddingRight="16dp" android:paddingTop="8dp"> <!-- PIN码输入框 --> <EditText android:id="@+id/pin_code" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="Enter your PIN code" android:inputType="numberPassword" android:padding="8dp" /> <!-- 数字键盘 --> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="1" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="2" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="3" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="4" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="5" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="6" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="7" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="8" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="9" /> </LinearLayout> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_marginTop="8dp" android:orientation="horizontal"> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="0" /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="." /> <Button android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="1" android:text="X" /> </LinearLayout> </LinearLayout> </RelativeLayout> ``` 在这个布局文件中,我们使用了一个 `RelativeLayout` 作为根布局。在根布局中,我们添加了一个 `Toolbar` 作为导航栏,并将其布局在顶部。接着,我们添加了一个 `LinearLayout` 作为 PIN 码键盘,并将其布局在底部。为了让 PIN 码键盘导航栏之间有一定的距离,我们可以设置 `Toolbar` 的 `android:layout_alignParentTop` 属性为 `true`,然后为 `LinearLayout` 设置 `android:layout_alignParentBottom` 属性为 `true`。 在 `LinearLayout` 中,我们添加了一个 `EditText` 作为 PIN 码输入框,并将其设置为 `numberPassword` 类型。接着,我们添加了一个纵向的 `LinearLayout` 作为数字键盘,并在其中添加了四个横向的 `LinearLayout`,每个包含三个 `Button`。为了让数字键盘与 PIN 码输入框之间有一定的距离,我们可以设置 `EditText` 的 `android:paddingTop` 属性为一定的值。同样地,为了让数字键盘中的每个 `Button` 之间有一定的距离,我们可以设置每个横向的 `LinearLayout` 的 `android:layout_marginTop` 属性为一定的值。
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值