小编bla*_*lau的帖子

自定义inputaccessoryView中的UITextView不会重新响应第一响应者状态

我有一个聊天应用程序实现浮动文本输入字段(类似于iOS消息应用程序)作为inputAccessoryView我的ChatViewController(请参阅Apple的文档).

class ChatViewController: UIViewController {

    override var inputAccessoryView: UIView? {
       return chatInputView
    }

    override var canBecomeFirstResponder: Bool {
        return true
    }
    ...
Run Code Online (Sandbox Code Playgroud)

ChatViewController有一个ChatTableViewController子视图控制器,它有包含UITextFields的单元格,其文本内容是可编辑的.我遇到的问题是,当用户点击一个单元格UITextField,在inputAccessoryViewUITextView拒绝辞职第一响应状态,以防止在内容UITableViewCell被编辑.控制台中记录以下警告:

 First responder warning: '<UITextView: 0x7fc041041c00; 
 frame = ...' rejected resignFirstResponder when being removed from hierarchy
Run Code Online (Sandbox Code Playgroud)

我已经打过电话resignFirstResponder,并endEditingUIInputViewUITextView直接,但没有成功.我不希望ChatViewController辞职第一响应者状态,因为这将导致inputAccessoryView消失.

编辑:我也会在交互式解除键盘时收到警告(而不是点击它UITableViewCellUITextField.

iphone ios swift

16
推荐指数
1
解决办法
3056
查看次数

BottomNavigationView 和 Android 导航不切换片段

我正在尝试使用BottomNavigationViewAndroid 导航来创建一个包含三个片段的标准选项卡式应用程序:StatusFragmentMapFragmentAlertsFragment

我的main_activity.xmlaFragmentContainerViewBottomNavigationView定义如下:

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".ui.main.MainActivity">

    <androidx.fragment.app.FragmentContainerView
        android:id="@+id/mainNavHostFragment"
        android:name="androidx.navigation.fragment.NavHostFragment"
        android:layout_width="match_parent"
        android:layout_height="0dp"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintBottom_toTopOf="@id/bottomNavigationView"
        app:defaultNavHost="true"
        app:navGraph="@navigation/main_nav_graph" />

    <com.google.android.material.bottomnavigation.BottomNavigationView
        android:id="@+id/bottomNavigationView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:menu="@menu/main_menu" />

</androidx.constraintlayout.widget.ConstraintLayout>
Run Code Online (Sandbox Code Playgroud)

我的main_nav_graph.xml

<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/main_nav_graph"
    app:startDestination="@id/mainActivity">
    <fragment
        android:id="@+id/statusFragment"
        android:name="<redacted>.ui.status.StatusFragment"
        android:label="StatusFragment" />
    <fragment
        android:id="@+id/mapFragment"
        android:name="<redacted>.ui.map.MapFragment"
        android:label="MapFragment" />
    <fragment
        android:id="@+id/alertsFragment"
        android:name="<redacted>.ui.alert.AlertsFragment"
        android:label="AlertsFragment" />
    <activity
        android:id="@+id/mainActivity"
        android:name="<redacted>.ui.main.MainActivity"
        android:label="main_activity" …
Run Code Online (Sandbox Code Playgroud)

android kotlin android-navigation android-architecture-navigation

1
推荐指数
1
解决办法
3782
查看次数