- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
大家好,我不断收到以下信息:
System.InvalidOperationException
和 “iOS 上不全局支持 PushAsync,请使用 NavigationPage。”
尽管我正在使用 NavigationPage
并且据我所知正在正确使用它。我的 F# 技能并不令人惊叹,所以我肯定认为我在这里做错了什么,但令人惊讶的是,在 F# 中很难找到执行 Navigation.PushAsync
的示例。我确实找到了这段代码,并且一直在寻找正确的示例。
https://github.com/fsprojects/Tamarin/blob/master/samples/Todo/TodoListMvc.fs
在示例中,我看到此代码封装在 async{}
do! this.Navigation.PushAsync(page = downcast view.Root) |> Async.AwaitIAsyncResult |> Async.Ignore
所以我认为我离这里并不太远。话虽如此,我做错了什么?
namespace Eclipsefest
open System
open Xamarin.Forms
open Xamarin.Forms.Xaml
type MenuItem =
{ Title : string
TargetType : System.Type }
type MenuPage() =
inherit ContentPage()
let _ = base.LoadFromXaml(typeof<MenuPage>)
member this.Handle_Tapped(sender : Object, arg : EventArgs) =
let navItem = sender :?> TextCell
async {
match navItem.Text with
| "Information" ->
do! this.Navigation.PushAsync(page = new NavigationPage(new InfoPage()))
|> Async.AwaitIAsyncResult
|> Async.Ignore
| "Events" ->
do! this.Navigation.PushAsync(new NavigationPage(new EventsPage()))
|> Async.AwaitIAsyncResult
|> Async.Ignore
| "BusRoute" ->
do! this.Navigation.PushAsync(new NavigationPage(new BusRoutePage()))
|> Async.AwaitIAsyncResult
|> Async.Ignore
| "Glasses" ->
do! this.Navigation.PushAsync(new NavigationPage(new GlassesPage()))
|> Async.AwaitIAsyncResult
|> Async.Ignore
| "Merch" ->
do! this.Navigation.PushAsync(new NavigationPage(new MerchPage()))
|> Async.AwaitIAsyncResult
|> Async.Ignore
| "Day" ->
do! this.Navigation.PushAsync(new NavigationPage(new DayPage()))
|> Async.AwaitIAsyncResult
|> Async.Ignore
| "About" ->
do! this.Navigation.PushAsync(new NavigationPage(new AboutPage()))
|> Async.AwaitIAsyncResult
|> Async.Ignore
| _ ->
do! this.Navigation.PushAsync(new NavigationPage(new EclipsefestPage()))
|> Async.AwaitIAsyncResult
|> Async.Ignore
}
|> Async.RunSynchronously
open System
open Xamarin.Forms
open Xamarin.Forms.Xaml
type MenuItem =
{ Title : string
TargetType : System.Type }
type MenuPage() =
inherit ContentPage()
let _ = base.LoadFromXaml(typeof<MenuPage>)
member this.Handle_Tapped(sender : Object, arg : EventArgs) =
this.Navigation.PushAsync(new NavigationPage(new EclipsefestPage())) |> ignore
我也尝试过这一点并收到了相同的错误。我怀疑我的问题与异步部分有关,但它似乎在没有异步的情况下引发了相同的异常。
open System
open Xamarin.Forms
open Xamarin.Forms.Xaml
type MenuItem =
{ Title : string
TargetType : System.Type }
type MenuPage() =
inherit ContentPage()
let _ = base.LoadFromXaml(typeof<MenuPage>)
member this.Handle_Tapped(sender : Object, arg : EventArgs) =
let page = new EclipsefestPage()
let navpage = new NavigationPage(page)
let result = this.Navigation.PushAsync(navpage)
result.RunSynchronously()
我开始感觉这是一个错误。我已验证页面和导航页面在调用 Navigation.PushAsync
之前已在各个步骤中实例化,但仍然遇到相同的异常。
“iOS 上全局不支持 PushAsync,请使用 NavigationPage。””
System.InvalidOperationException: PushAsync is not supported globally on iOS, please use a NavigationPage.
at Xamarin.Forms.Platform.iOS.Platform.Xamarin.Forms.INavigation.PushAsync (Xamarin.Forms.Page root, System.Boolean animated) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Platform.cs:154
at Xamarin.Forms.NavigationProxy.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00022] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:190
at Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page root, System.Boolean animated) [0x00013] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:109
at Xamarin.Forms.NavigationProxy.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00022] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:190
at Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page root, System.Boolean animated) [0x00013] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:109
at Xamarin.Forms.NavigationProxy.OnPushAsync (Xamarin.Forms.Page page, System.Boolean animated) [0x00022] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:190
at Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page root, System.Boolean animated) [0x00013] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:109
at Xamarin.Forms.NavigationProxy.PushAsync (Xamarin.Forms.Page root) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\NavigationProxy.cs:102
at <StartupCode$Eclipsefest>.$MenuPage.xaml+Handle_Tapped@17.Invoke (Microsoft.FSharp.Core.Unit unitVar) [0x00090] in /Users/terrancesmith/Projects/Eclipsefest/Eclipsefest/MenuPage.xaml.fs:19
at Microsoft.FSharp.Control.AsyncBuilderImpl+callA@851[b,a].Invoke (Microsoft.FSharp.Control.AsyncParams`1[T] args) [0x00047] in <5584acdb904cf4daa7450383dbac8455>:0
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw () [0x0000c] in /Library/Frameworks/Xamarin.iOS.framework/Versions/10.10.0.36/src/mono/mcs/class/referencesource/mscorlib/system/runtime/exceptionservices/exceptionservicescommon.cs:151
at Microsoft.FSharp.Control.AsyncBuilderImpl.commit[a] (Microsoft.FSharp.Control.AsyncBuilderImpl+Result`1[T] res) [0x00030] in <5584acdb904cf4daa7450383dbac8455>:0
at Microsoft.FSharp.Control.CancellationTokenOps.RunSynchronously[a] (System.Threading.CancellationToken token, Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpOption`1[T] timeout) [0x000a3] in <5584acdb904cf4daa7450383dbac8455>:0
at Microsoft.FSharp.Control.FSharpAsync.RunSynchronously[T] (Microsoft.FSharp.Control.FSharpAsync`1[T] computation, Microsoft.FSharp.Core.FSharpOption`1[T] timeout, Microsoft.FSharp.Core.FSharpOption`1[T] cancellationToken) [0x00071] in <5584acdb904cf4daa7450383dbac8455>:0
at Eclipsefest.MenuPage.Handle_Tapped (System.Object sender, System.EventArgs arg) [0x00008] in /Users/terrancesmith/Projects/Eclipsefest/Eclipsefest/MenuPage.xaml.fs:16
at Xamarin.Forms.Cell.OnTapped () [0x00008] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Cells\Cell.cs:106
at Xamarin.Forms.TextCell.OnTapped () [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\Cells\TextCell.cs:82
at Xamarin.Forms.TableView+TableSectionModel.OnRowSelected (System.Object item) [0x00007] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TableView.cs:214
at Xamarin.Forms.TableModel.RowSelected (System.Object item) [0x0001a] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TableModel.cs:65
at Xamarin.Forms.TableModel.RowSelected (System.Int32 section, System.Int32 row) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Core\TableModel.cs:57
at Xamarin.Forms.Platform.iOS.TableViewModelRenderer.RowSelected (UIKit.UITableView tableView, Foundation.NSIndexPath indexPath) [0x00000] in C:\BuildAgent3\work\ca3766cfc22354a1\Xamarin.Forms.Platform.iOS\Renderers\TableViewModelRenderer.cs:85
at at (wrapper managed-to-native) UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at UIKit.UIApplication.Main (System.String[] args, System.IntPtr principal, System.IntPtr delegate) [0x00005] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:79
at UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00038] in /Users/builder/data/lanes/4691/d2270eec/source/xamarin-macios/src/UIKit/UIApplication.cs:63
at Eclipsefest.iOS.Main.main (System.String[] args) [0x00001] in <59853c0a6da8a60ca74503830a3c8559>:0
最佳答案
来自 Xamarin 人员的回答。
In the code you showed, you are wrapping the new page you want to push in a NavigationPage. However it's the page you are pushing from that needs to be in a navigation page.
The easiest way to do this is to wrap your initial page in a NavigationPage then set it as the MainPage. Then you just push the new pages directly without wrapping them in another NavigationPage because doing so will cause other issues. Check it out:
https://gist.github.com/jimmgarrido/d0b702c1282faa5bb91d0ed14e2d7e1b
namespace FForms
open System
open Xamarin.Forms
type TestPage() as this =
inherit ContentPage()
let nextBtn = Button(Text = "Next Page")
let layout = StackLayout()
let handler = EventHandler(fun sender args ->
let newPage = ContentPage(BackgroundColor = Color.Red)
do this.Navigation.PushAsync(newPage))
do nextBtn.Clicked.AddHandler handler
do layout.Children.Add nextBtn
do base.Content <- layout
type App() =
inherit Application(MainPage = NavigationPage(TestPage()))
Hope this helps!
确实如此~
关于ios - 使用 NavigationPage 时获取 "PushAsync is not supported globally on iOS...",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45524358/
我收到多行错误,指出它有重复的类 Duplicate class android.support.v4.accessibilityservice.AccessibilityServiceInfoCom
我的项目昨天运行良好,今天却出现以下错误。请帮忙。 出了什么问题:无法解析配置“:app:debugCompileClasspath”的所有文件。 Could not find support-v4.
错误:配置项目“:app”时出现问题。 Could not find support-v4.jar (com.android.support:support-v4:24.0.0). Searched
我正在使用 react-native-webrtc 运行示例应用程序模块。我正在尝试在 android 中运行该应用程序,但出现这样的错误... * What went wrong: A probl
错误:配置项目“:app”时出现问题。 Could not find support-v4.jar (com.android.support:support-v4:24.0.0). Searched
我克隆了我的项目并使用 Android studio 打开,但构建失败并出现以下错误并且同一个项目在其他项目上运行良好。 出了什么问题:无法解析配置“:app:flavorUnsignedReleas
我正在运行示例应用程序......我正在使用 this模块.....但是我收到这样的错误... FAILURE: Build failed with an exception. * What went
我有一个 Ionic 项目,在升级到 OSx Mojave 后,出于某种原因不再构建。 该项目基于 Ionic 3 构建。 我有 Cordova CLI 7.0.0 当我运行时 ionic cordo
我有一个 Ionic 项目,在升级到 OSx Mojave 后,出于某种原因不再构建。 该项目基于 Ionic 3 构建。 我有 Cordova CLI 7.0.0 当我运行时 ionic cordo
添加 Android 平台(ionic cordova platform add android)后,我构建了我的 Ionic 项目(ionic cordova build android),但出现错
这个问题在这里已经有了答案: Manifest merger failed : Attribute application@appComponentFactory - Androidx (14 个答
关于我的 Gradle 文件中的以下“complie”: dependencies { compile 'com.android.support:support-v4:25.3.1' }
有些困惑。 我想更频繁地使用@supports 但是...我不关心浏览器如何看待它。希望您能说清楚,如果可以的话谢谢您。 如果浏览器本身不理解@supports,它如何计算@support 'not'
我刚刚升级到 Dart 2 和最新版本的 Flutter,现在我无法构建我的应用程序。我在互联网上环顾四周,但仍然不明白为什么会发生这种情况。 我得到的错误是: FAILURE: Build fail
我正在学习 Firebase,但由于以下错误而陷入困境: Error:Failed to resolve: com.android.support:customtabs:25.4.0 Error:Fa
我在构建本周时出于某种原因尝试使用Cordova进行项目时遇到问题: cordova build android gradle获取com.android.support:support alpha而不
对应的androidx是什么com.android.support:support-compat 的图书馆实现push notifications ? 他们说here它是 androidx 的一部分,
我正在尝试为我的应用设置插桩单元测试。并且我已根据以下开发者站点链接添加了依赖项。 https://developer.android.com/training/testing/unit-testin
当我想使用 Proguard 规则生成签名的 APK(发布)时,我收到了以下错误消息: Cannot find a version of 'com.android.support:support-an
这个问题在这里已经有了答案: Failed to resolve: com.android.support:appcompat-v7:26.0.0 (14 个答案) Failed to resolv
我是一名优秀的程序员,十分优秀!