ipad - 从 TabBarController 调用带有 Button 的 ViewController
问题描述
我想在我的 Xamarin.ios 应用程序中调用几个视图。这个应用程序有一个 TabBarController,它可以正常工作。现在我想调用添加到我的 TabBarController 中的视图,并在 MainPage 上使用按钮。
用户应该走的方式应该是这样的:
- 单击显示 ActionSheet 的图片(按钮)。这显示了有关侧面的简短说明,并提供了两个选项,“确定”和“显示视图”。
- 用户按下“显示视图”,将显示侧面。<-这是问题所在。
我尝试了以下方法:
this.TabBarController.PresentViewController(this.TabBarController.ViewControllers[1], true, null);
和
TabBarController.SelectedIndex = 1;
PerformSegue("Einstellungen", sender: this.TabBarController);
但没有任何效果。我刚刚收到一些错误,应用程序崩溃了......
有人可以给我一个好主意吗?
解决方案
要更改 UITabBarController 的选项卡,您所要做的就是更改当前索引。
this.TabBarController.SelectedIndex =*TabIndex*;
TabBarController 是您的 UITabBarController 对象的引用,请确保您在 MainThread 上执行此操作,并且一切正常。
请检查此以获取更多详细信息https://docs.microsoft.com/en-us/xamarin/ios/user-interface/controls/creating-tabbed-applications
如果您有任何疑问,请随时回复
推荐阅读
- perl - 将 .mhtml 文件测试为 .t
- key - Gnuplot:水平键排序(转置)
- javascript - 文档在有效数据上创建后不保存数据
- php - 在 CakePHP 4 配置中读取为字符串的布尔值
- text-mining - 如何让 XGBoost 输出为 int,而不是对象?
- r - 使用具有两组坐标的 distGeo
- flutter - 如何使用颤振阅读应用程序购买状态?(in_app_purchase 包)
- keras - keras 中的 LSTM,输入形状,时间步长与 nfeatures
- animation - 单击时没有播放 Roblox 动画
- file-upload - 自定义上传按钮