简体   繁体   English

Xamarin iOS-模拟器视图未刷新

[英]Xamarin iOS - Simulator View is not refreshing

I have a simple piece of code built in Xamarin for iOS in my ViewController : 我在ViewController中有一个简单的代码在Xamarin for iOS中内置:

    void LogMessage (string message)
    {
        logText.Text += string.Format("\n{0}", message));
    }

where logText is: 其中logText是:

    [Outlet]
    [GeneratedCode ("iOS Designer", "1.0")]
    UILabel logText { get; set; }

The code is being called, the Text property of the logText is being updated properly, but in iOS Simulator I see no change at all. 代码被调用,logText的Text属性正在正确更新,但是在iOS Simulator中,我看不到任何更改。 I tried replacing UILabel with UITextView but nothing changes. 我尝试用UITextView替换UILabel ,但是没有任何变化。

If you are trying to update the UI from a background thread, it will not work. 如果您尝试从后台线程更新UI,它将无法正常工作。 To force the update on the UI thread, try this 要在UI线程上强制进行更新,请尝试以下操作

InvokeOnMainThread (delegate {  
    logText.Text += string.Format("\n{0}", message));
});

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

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