locked
HTML-content in ViewCell RRS feed

  • Question

  • User393142 posted

    Hello everyone!

    I am trying to display a label with TextType HTML. When I put the app to background or when I bring it back to foreground I get the following crash:

    ``` Objective-C exception thrown. Name: NSInternalInconsistencyException Reason: unexpected start state

    ``` I've had this problem before but didn't manage to solve it. I have tried a few different nugets for HTML-cells, but get the same crash.

    Has anyone had this problem and figured out how to solve it?

    I am also wondering if there is any way of supporting more HTML/CSS on Android. With my test project on iOS (before the crash) I get all the styling defined. But with Android I am just getting basic (bold, cursive etc) styling.

    Thank you, Daniel

    Tuesday, September 1, 2020 8:36 AM

All replies

  • User382871 posted

    When I put the app to background or when I bring it back to foreground I get the following crash I created a basic sample to test the label with TextType HTML on ios and it works fine. The crash may be not caused by the label. What's the version of Xamarin.Forms package and Xamarin.iOS sdk did you use in the project? Try to update to the lastest stable version and test again.

    I get all the styling defined. But with Android I am just getting basic (bold, cursive etc) styling. You could use the WebView to display the html content or try the Xam.Plugin.HtmlLabel plugin.

    Tuesday, September 1, 2020 11:52 AM
  • User393142 posted

    Sorry. I should have made it more clear. I am trying to use a label with TextType HTML inside a viewCell.

    I believe just putting a label works fine. I am sure that it is the problem, because when I remove the cell with the label it will work.

    I have tried the plugin you mentioned, but I get the same issue.

    My iOS is set to 13.6 Xamarin.forms version is 4.8.0.1364

    Tuesday, September 1, 2020 3:42 PM
  • User382871 posted

    I am trying to use a label with TextType HTML inside a viewCell ... when I remove the cell with the label it will work. I tested the function code in a ListView and it also works well. How did you place the viewCell? Could you share a basic demo to reproduct the issue? <ListView> ... <ListView.ItemTemplate> <DataTemplate> <ViewCell> <Label TextType="Html" Text="{Binding .}"/> </ViewCell> </DataTemplate> </ListView.ItemTemplate> </ListView>

    Wednesday, September 2, 2020 9:51 AM
  • User393142 posted

    I made a test project that has the same functionality as my original project, and while the app didn't crash the first time, on the third time after putting it to background and back to foreground, I got the same crash.

    I made a repo with my code @ https://github.com/DanielHJA/CrashingXamarinHTMLCell

    Thank you for trying to help me!

    / Daniel

    Wednesday, September 2, 2020 1:38 PM
  • User382871 posted

    I tested the sample from the link and face the same issue as you descriped. Test but not get the reason now. If I comment the Model.FetchJSON command, it'll work fine. ``` public partial class MainPage : ContentPage { MainPageViewModel Model = new MainPageViewModel();

    public MainPage()
    {
        InitializeComponent();
        BindingContext = Model;
        //Model.FetchJSON();
    }
    

    } ```

    I created a basic sample to reproduce the code, it works well. I posted the demo file, you could check that. Try creating a new project and copy the code from the previous sample.

    Thursday, September 3, 2020 10:13 AM
  • User393142 posted

    Sorry for the delayed response!

    Thank you for making the project, but I get the same error from your demo. It took 3-6 times to go background -> foreground before crashing. One of my friends gets the same error as me.

    Seems to be related to when Xamarin needs to use the NSAtrributedstring to create the HTML, but not really sure where to go from here.

    Thanks again for your help

    Friday, September 4, 2020 12:09 PM
  • User382871 posted

    Sorry for my mistake, I faced the same issue when deploying the code. If remove the TextType = Html, it'll works fine. And there is nothing wrong with the Android platform. This may be a potential issue, you could report it to the product team on github.

    https://github.com/xamarin/Xamarin.Forms/issues/new/choose

    Monday, September 7, 2020 2:18 PM
  • User393142 posted

    @Jarvan said: Sorry for my mistake, I faced the same issue when deploying the code. If remove the TextType = Html, it'll works fine. And there is nothing wrong with the Android platform. This may be a potential issue, you could report it to the product team on github.

    https://github.com/xamarin/Xamarin.Forms/issues/new/choose

    I submitted a bug report and will leave this issue open in case someone in the product team has a solution so I can post it here :).

    Thank you!

    Monday, September 7, 2020 3:42 PM
  • User382871 posted

    Here is the link of the topic. If others face the similar, check this link. https://github.com/xamarin/Xamarin.Forms/issues/12045

    Tuesday, September 8, 2020 7:09 AM