标签: navigationcontroller

Android:找不到`androidx.navigation.NavArgs`

我从下面的代码中获取 来自 Codelab 的导航控制器

但是得到以下错误:已经花费了 3 个小时,但没有任何成功。 这是我的错误

请帮我解决这个错误。

android navigationcontroller android-jetpack androidx

7
推荐指数
3
解决办法
9386
查看次数

在dismissModalViewControllerAnimated之后调用popToRootViewControllerAnimated

我正在工作的应用程序,我打电话presentModalViewController,一旦完成(调用dismissModalViewControllerAnimated:YES)它应立即调用popToRootViewControllerAnimated.

但问题是dismissModalViewControllerAnimated:YES工作正常,但popToRootViewControllerAnimated不能正常工作.

代码如下所示:

[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self.navigationController popToRootViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud)

objective-c navigationcontroller ios

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

xcode4.2.1 - storyboard - 导航控制器 - 标题栏颜色

我正在设计一个带有最少编码的故事板的应用程序.所以,我使用视图和按钮设计所有内容,而不需要头文件.

使用最少编码将默认蓝色标题栏颜色更改为黑色的最简单方法是什么?

xcode titlebar storyboard navigationcontroller

5
推荐指数
2
解决办法
1万
查看次数

嵌入导航控制器的目的是什么?

我最近一直在学习iOS开发,一位朋友告诉我,将视图嵌入导航控制器是一种好习惯。是真的,如果是,为什么呢?

将视图控制器嵌入导航控制器与仅将视图控制器单独放置相比有什么变化?

navigationcontroller ios ios7

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

如何使用 Swift 将搜索栏移动到导航栏?

所以我想知道如何将我的应用程序中的搜索栏(当前显示在导航栏下方)移动到导航栏中。

现在,我有一个名为 makeSearchBar() 的函数,我在 viewDidLoad() 中调用它来制作搜索栏。没有故事板或 xib 文件。我想去掉导航栏上的标题,用搜索栏代替。但是,当我使用其他用户问题中给出的方法时,搜索栏要么消失了,要么保持在原处。

在此处输入图片说明

这是搜索栏的代码:

override func viewDidLoad() {
        super.viewDidLoad()
        makeSearchBar()
}

func makeSearchBar() {
        searchBar = UISearchBar()
        searchBar.delegate = self
        searchBar.frame = CGRect(x: 0, y: 0, width: screenSize.width, height: 60)

       // searchBar.sizeToFit()

       //TRYING TO ADD TO NAV BAR
       navigationItem.titleView = searchBar

        searchBar.placeholder = "Search"

        view.addSubview(searchBar)
}
Run Code Online (Sandbox Code Playgroud)

我还想知道如何使应该使电池信息具有不同背景颜色的顶行。

如果您有任何建议,我很乐意听取他们的意见。我是 iOS 新手,不确定自己在做什么。

uisearchbar navigationcontroller navigationbar ios swift

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

导航控制器和广播接收器

NavigationController我目前在从上​​下文中查找实例时遇到问题BroadcastReceiver。当我findNavigationController()从其他任何地方调用Fragment它时,它导航没有任何问题,但是当我从以下上下文中调用它时onReceive应用程序的上下文中调用它时,它会崩溃并出现以下异常

\n\n
 Caused by: java.lang.IllegalArgumentException: navigation destination app.eventcloud.events:id/action_documents_list_fragment_to_document_viewer_fragment is unknown to this NavController\n    at androidx.navigation.NavController.navigate(NavController.java:633)\n    at androidx.navigation.NavController.navigate(NavController.java:592)\n    at app.eventcloud.root.gui.screens.knowledgehub.DocumentsListFragment.handleDownloadCompleted(DocumentsListFragment.kt:97)\n    at app.eventcloud.root.gui.screens.knowledgehub.DocumentsListFragment.access$handleDownloadCompleted(DocumentsListFragment.kt:26)\n    at app.eventcloud.root.gui.screens.knowledgehub.DocumentsListFragment$receiver$1.onReceive(DocumentsListFragment.kt:143)\n    at android.app.LoadedApk$ReceiverDispatcher$Args.lambda$getRunnable$0(LoadedApk.java:1391)\n    at android.app.-$$Lambda$LoadedApk$ReceiverDispatcher$Args$_BumDX2UKsnxLVrE6UJsJZkotuA.run(Unknown Source:2)\xc2\xa0\n    at android.os.Handler.handleCallback(Handler.java:873)\xc2\xa0\n    at android.os.Handler.dispatchMessage(Handler.java:99)\xc2\xa0\n    at android.os.Looper.loop(Looper.java:193)\xc2\xa0\n    at android.app.ActivityThread.main(ActivityThread.java:6669)\xc2\xa0\n    at java.lang.reflect.Method.invoke(Native Method)\xc2\xa0\n    at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)\xc2\xa0\n    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)\xc2\xa0\n
Run Code Online (Sandbox Code Playgroud)\n\n

导致问题的代码如下。

\n\n
private val receiver: BroadcastReceiver = object : BroadcastReceiver() {\n    override fun onReceive(context: Context, intent: Intent) {\n        val action = intent.action\n        if (DownloadManager.ACTION_DOWNLOAD_COMPLETE == action) {\n …
Run Code Online (Sandbox Code Playgroud)

android broadcastreceiver navigationcontroller

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

在导航控制器上添加片段而不是替换片段?

我正在使用导航控件(Android体系结构)。我使用了一些演示并创建了导航架构。但是问题是,片段每次都会被召回,就像:从任何片段返回时都替换片段。因此,如何停止此操作,以及如何设置类似“添加片段”而不是“替换片段”的行为。

我在网络上发现了这个问题,但是没有人给我关于如何在导航控件上添加/替换片段的想法。我尝试使用片段ID来获取添加片段的方法,但未成功。

  1. 这是我的导航主机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/nav_graph"
            app:startDestination="@id/questionanswer">

            <fragment
                android:id="@+id/questionanswer"
                android:name="com.softtech360.totalservey.fragment.QuestionAnswer"
                android:label="fragment_first"
                tools:layout="@layout/questionanswer" >
                <action
                    android:id="@+id/action_questionanswer_to_questionanswer"
                    app:destination="@id/questionanswer"

                    />
            </fragment>
</navigation>
Run Code Online (Sandbox Code Playgroud)
  1. 我创建了一个按钮,每次触发该函数并在主机片段上交换片段时,都会使用此按钮进行调用:
val navController = Navigation.findNavController(activity!!,R.id.navhost_fragment)
                            navController.navigate(R.id.questionanswer)
        // using this i swap the fragment on host fragment.
Run Code Online (Sandbox Code Playgroud)

android navigationcontroller android-fragments

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

如何使用导航从bottomsheetdialog导航到片段?

我目前正在制作一个具有底部功能的应用程序,当用户点击对话框内的图标(图像视图)时,片段将显示出来。我的问题是我无法导航到片段 b 并且它返回了这个错误在此处输入图片说明

这是我的主页片段,活动启动时第一个开始的片段

public class HomeFrag extends Fragment {

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_home, container, false);
    ImageView buttonOpenSheet = view.findViewById(R.id.buttonopensheet);

    buttonOpenSheet.setOnClickListener(new View.OnClickListener() {
        @Override
        public void onClick(View v) {
            BottomSheetDialog bottomsheet = new BottomSheetDialog();
            bottomsheet.show(getFragmentManager(), "bottomsheet");
        }
    });

    return view;
}}
Run Code Online (Sandbox Code Playgroud)

底部对话框.java

public class BottomSheetDialog extends BottomSheetDialogFragment {

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
    final View view = …
Run Code Online (Sandbox Code Playgroud)

android uinavigationcontroller navigationcontroller android-jetpack

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

如何为 mac/cocoa App 设计 NavigationController?

我想为 mac 应用程序(Cocoa 桌面应用程序)设计导航流程,与带有导航栏和后退按钮的 NavigationController 相同。还有推/弹出操作。与 mac AppStore 导航相同。附上屏幕截图以供快速参考。

有可用的 mac 组件或任何第三方资源吗?屏幕1

屏幕2

macos cocoa navigationcontroller

5
推荐指数
0
解决办法
260
查看次数

大标题在推送后最初折叠

我遇到了一个奇怪的问题:

\n
    \n
  • 我有两个视图控制器 - 列表和详细信息。
  • \n
  • 当我从列表中推送详细信息时,导航栏处于折叠模式。
  • \n
  • 为了使标题显得更大,我必须向下滚动。
  • \n
\n

列表视图控制器:

\n
...\noverride func viewDidLoad() {\n    super.viewDidLoad()\n\n    setupNavigationBar()\n}\n\nprivate func setupNavigationBar() {\n    navigationController?.navigationBar.prefersLargeTitles = true\n    navigationItem.largeTitleDisplayMode = .never\n}\n...\n
Run Code Online (Sandbox Code Playgroud)\n

详细视图控制器:

\n
...\noverride func viewDidLoad() {\n    super.viewDidLoad()\n\n    setupNavigationBar()\n}\n\nprivate func setupNavigationBar() {\n    title = "Bangkok \xe2\x87\x84 Phuket"\n    navigationController?.navigationBar.prefersLargeTitles = true\n    navigationItem.largeTitleDisplayMode = .always\n}\n...\n
Run Code Online (Sandbox Code Playgroud)\n

经过一番调查,我发现只有当我在标题中输入某些字符时才会出现该错误:

\n
    \n
  • 当标题为“Bangkok \xe2\x86\x92 Phuket”时,一切按预期进行
  • \n
  • 当标题为“Bangkok \xe2\x87\x84 Phuket”时,推送的控制器标题会折叠
  • \n
\n

你们知道标题中的字符有什么限制吗,或者有什么解决办法吗?谢谢,非常感谢任何帮助

\n

navigationcontroller ios swift ios13

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