简体   繁体   English

Xamarin.Forms标签在iOS上不再起作用

[英]Xamarin.Forms labels not working anymore, on iOS

I am making a Xamarin.Forms project, and I am in the end of my app, but something really strange have happened. 我正在制作一个Xamarin.Forms项目,而我的应用程序已结束,但是确实发生了一些奇怪的事情。 My app starts up with no labels (!?), meaning they are invisible or not created at all. 我的应用程序启动时没有标签(!?),这意味着它们不可见或根本没有创建。 Everything else seems to be working, until I press a button that is supposed to change the label - when I do this, the app freezes. 直到我按下应该用来更改标签的按钮,其他所有东西似乎都在起作用-当我这样做时,应用程序冻结。 I get no exception in Visual Studio, though. 我在Visual Studio中也没有例外。

One problem is that my breakpoints in PLC code never hits, only those I place in the iOS code. 一个问题是,我在PLC代码中的断点从未命中,只有我放置在iOS代码中的那些断点。 However, the buttons not related to changing a label works, so I know the PLC code have been ran. 但是,与更改标签无关的按钮有效,因此我知道PLC代码已经运行。 If I let the app run for a little while, and then press the pause-button in VS debugging to see where in the code I am, it stops at 如果我让应用程序运行一会儿,然后在VS调试中按“暂停”按钮以查看我在代码中的位置,则它会停止在

UIApplication.Main(args, null, "AppDelegate");

.. in Main.cs. ..在Main.cs中。 I dont know if this is correct or not, when I run on Android, I get a Break Mode - No code is currently running. 我不知道这是否正确,当我在Android上运行时,出现“中断模式”-当前未运行任何代码。

I have been trying for hours to debug, reinstall, restart, clean and rebuild, but nothing seems to help. 我已经尝试了几个小时来调试,重新安装,重新启动,清理和重建,但是似乎无济于事。 My code works perfectly in Android, and it worked in iOS 1 week ago. 我的代码在Android上运行良好,并且在一周前在iOS上运行。 Anyone have any ideas what is going on, or what I can do to debug some more? 任何人都知道发生了什么,或者我可以做些什么调试呢? Or must I make a new project and try start over? 还是我必须创建一个新项目并尝试重新开始?

Edit: I have also tried different starting pages, and all are the same: all views loads except those with text in them. 编辑:我也尝试了不同的起始页,并且都是相同的:所有视图加载,除了其中包含文本的视图。 I have a page with an Editor in it, and I can write in it, but no text is appearing inside of it. 我有一个带有编辑器的页面,可以在其中写,但是里面没有文本。 Only button have visible text. 只有按钮具有可见的文本。 I do not use a custom font for my labels, I have not specified anything. 我没有为标签使用自定义字体,我没有指定任何内容。

Waking up fresh in the morning, I found my issue in 15 minutes.. 早晨刚醒来,我在15分钟内发现了问题。

After altering my Google search to TextView iOS instead of Label Xamarin, I found much more answers. 将Google搜索更改为TextView iOS而不是Label Xamarin之后,我发现了更多答案。 Thanks to this question and answer. 感谢这个问题和答案。

Basically, changing anything on the labels in the constructor of the page (even after InitializeComponent()), will mess up the view. 基本上,更改页面构造函数中标签上的所有内容(即使在InitializeComponent()之后)也会使视图混乱。 I moved my code outside of the constructor (in the protected override void OnAppearing() method), and now it is working again. 我将代码移到了构造函数之外(在受保护的重写void OnAppearing()方法中),现在它又可以正常工作了。

The freeze part was not related - this was my custom menu that covered my screen with an invisible layout eating up all clicking events. 冻结部分不相关-这是我的自定义菜单,该菜单以不可见的布局覆盖了我的屏幕,吞噬了所有单击事件。 A bit confusing, none of these issues are present in Android, but there you go. 有点令人困惑,Android中不存在这些问题,但是您就可以了。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM