我正在工作的应用程序,我打电话presentModalViewController
,一旦完成(调用dismissModalViewControllerAnimated:YES
)它应立即调用popToRootViewControllerAnimated
.
但问题是dismissModalViewControllerAnimated:YES
工作正常,但popToRootViewControllerAnimated
不能正常工作.
代码如下所示:
[self.navigationController dismissModalViewControllerAnimated:YES] ;
[self.navigationController popToRootViewControllerAnimated:YES];
Run Code Online (Sandbox Code Playgroud) 我正在设计一个带有最少编码的故事板的应用程序.所以,我使用视图和按钮设计所有内容,而不需要头文件.
使用最少编码将默认蓝色标题栏颜色更改为黑色的最简单方法是什么?
我最近一直在学习iOS开发,一位朋友告诉我,将视图嵌入导航控制器是一种好习惯。是真的,如果是,为什么呢?
将视图控制器嵌入导航控制器与仅将视图控制器单独放置相比有什么变化?
所以我想知道如何将我的应用程序中的搜索栏(当前显示在导航栏下方)移动到导航栏中。
现在,我有一个名为 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 新手,不确定自己在做什么。
NavigationController
我目前在从上下文中查找实例时遇到问题BroadcastReceiver
。当我findNavigationController()
从其他任何地方调用Fragment
它时,它导航没有任何问题,但是当我从以下上下文中调用它时onReceive
应用程序的上下文中调用它时,它会崩溃并出现以下异常
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\nprivate 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体系结构)。我使用了一些演示并创建了导航架构。但是问题是,片段每次都会被召回,就像:从任何片段返回时都替换片段。因此,如何停止此操作,以及如何设置类似“添加片段”而不是“替换片段”的行为。
我在网络上发现了这个问题,但是没有人给我关于如何在导航控件上添加/替换片段的想法。我尝试使用片段ID来获取添加片段的方法,但未成功。
<?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)
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) 我目前正在制作一个具有底部功能的应用程序,当用户点击对话框内的图标(图像视图)时,片段将显示出来。我的问题是我无法导航到片段 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
我想为 mac 应用程序(Cocoa 桌面应用程序)设计导航流程,与带有导航栏和后退按钮的 NavigationController 相同。还有推/弹出操作。与 mac AppStore 导航相同。附上屏幕截图以供快速参考。
我遇到了一个奇怪的问题:
\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你们知道标题中的字符有什么限制吗,或者有什么解决办法吗?谢谢,非常感谢任何帮助
\nandroid ×4
ios ×4
swift ×2
androidx ×1
cocoa ×1
ios13 ×1
ios7 ×1
macos ×1
objective-c ×1
storyboard ×1
titlebar ×1
uisearchbar ×1
xcode ×1