UILabel没有在ScrollView中显示大内容

时间:2016-08-31 09:46:06

标签: html ios uiscrollview uilabel

我的ScrollView的ContentView只包含一个UILabel,它有前导空格8,尾随空格8,顶部空间到容器8dp,数字行设置为0. ScrollView ContentView高度为9000。

我正在向标签动态添加一个大的html内容..

public override void ViewDidLoad()
{
    base.ViewDidLoad();
    var attr = new NSAttributedStringDocumentAttributes();
    var nsError = new NSError();
    attr.DocumentType = NSDocumentType.HTML;
    contentLabel.AttributedText = new NSAttributedString(GetContent(), attr, ref nsError);

    contentLabel.Font = UIFont.FromName("Helvetica", 11f);
    contentLabel.Layer.BorderWidth = 1f;
    contentLabel.Layer.BorderColor = AZConstants.SeparatorColor.CGColor;
    contentLabel.Layer.CornerRadius = 4f;
    contentLabel.ClipsToBounds = true;
}

string GetContent()
{
        var myHtmlText = "<h4 style=\"text-align: center;\">TERMS OF SERVICE AGREEMENT</h4>\n <p>\n " +
            "PLEASE READ THE FOLLOWING TERMS OF USE AGREEMENT CAREFULLY. BY ACCESSING OR USING OUR SITES AND OUR SERVICES, YOU HEREBY AGREE\n " +
            "TO BE BOUND BY THE TERMS AND ALL TERMS INCORPORATED HEREIN BY REFERENCE. IF YOU DO NOT EXPRESSLY AGREE TO ALL OF THE TERMS AND CONDITIONS, THEN PLEASE DO\n" +
            "NOT ACCESS OR USE OUR SITES OR OUR SERVICES. THIS TERMS OF SERVICE AGREEMENT IS LAST REVISED AS  OF July 1, 2014. \n </p>";

        myHtmlText += "<h4>ACCEPTANCE OF TERMS</h4>";
        myHtmlText += "<p>\n The following Terms of Service Agreement (the \"TOS\") is a legally binding agreement that shall " +
            "govern the relationship with our users and others which may\n interact or interface with Simple Healthcare LLC " +
            "(SHL), also known as Green Circle Health(GCH), located at 5 Portofino Drive, Suite 2101, Pensacola Beach, " +
            "Florida 32561, and our\n subsidiaries and affiliates, in association with the use of the SHL websites, which includes " +
            "GOGCH.COM (the \"Site\") and its services (\"Services\"), which shall be defined below.\n </p>";
        myHtmlText += "<h4>DESCRIPTION OF SERVICES OFFERED</h4>\n <p>\n Green Circle Health (GCH) is a platform for patients to store " +
            "and share personal medical data including vitals and documents. GCH provides medical forms needed to check-in at a medical " +
            "facility. GCH enables remote monitoring of patient vitals and fitness activities for population health management and " +
            "clinical research trials.\n </p>";
        myHtmlText += "<p>\n <strong>GCH enables you to store your personal data</strong>\n </p>";
        myHtmlText += "<p>\n Any and all visitors to our site, despite whether they are registered or not, shall be deemed " +
            "as \"users\" of the herein contained Services provided for the\n  purpose of this TOS. Once an individual registers " +
            "for our Services, through the process of creating an account, the user shall then be considered a\n  \"member.\"\n </p>";
        myHtmlText += "<p>\n The user and/or member acknowledges and agrees that the Services provided and made available through " +
            "our website and applications, which may include some\n mobile applications and that those applications may be made " +
            "available on various social media networking sites and numerous other platforms and\n downloadable programs, are " +
            "the sole property of SHL. At its sole discretion, SHL may offer additional websites or services and/or products, " +
            "or update, modify or\n revise any current content and Services, and this Agreement shall apply to any and all " +
            "additional services and/or products and any and all updated,\n modified or revised Services unless otherwise " +
            "stipulated. SHL does hereby reserve the right to cancel and cease offering any of the aforementioned Services\n " +
            "and/or products. You, as the end user and/or member, acknowledge, accept and agree that SHL shall not be held " +
            "liable for any such updates, modifications,\n revisions, suspensions or discontinuance of any of our Services " +
            "and/or products. Your continued use of the Services provided, after such posting of any\n  updates, changes, and/or " +
            "modifications shall constitute your acceptance of such updates, changes and/or modifications, and as such, " +
            "frequent review of this\n Agreement and any and all applicable terms and policies should be made by you to " +
            "ensure you are aware of all terms and policies currently in effect. Should\n " +
            "you not agree to the updated, modified, revised or modified terms, you must stop using the provided Services.\n </p>";
        myHtmlText += "<p>\n Furthermore, the user and/or member understands, acknowledges and agrees that the Services offered " +
            "shall be provided \"AS IS\" and as such SHL shall not assume any responsibility or obligation for the timeliness, " +
            "missed delivery, deletion and/or any failure to store user content, communication or personalization settings.\n</p>";
        myHtmlText += "<h4>REGISTRATION</h4>\n <p>\n To register and become a \"member\" of the Site, you must be 18 years of age " +
            "to enter into and form a legally binding contract. In addition, you must be in\n good standing and not an individual " +
            "that has been previously barred from receiving SHL's Services under the laws and statutes of the United States or " +
            "other\n applicable jurisdiction.\n </p>";
        myHtmlText += "<p>\nFurthermore, the registering party hereby acknowledges, understands and agrees to:\n</p>";
        myHtmlText += "<ol type=\"a\">\n <li>\n furnish factual, correct, current and complete information with regards to yourself " +
            "as may be requested by the data registration process, and\n  </li>\n <li>\n  maintain and promptly update your " +
            "registration and profile information in an effort to maintain accuracy and completeness at all times.\n  </li>\n </ol>";
        myHtmlText += "<p>\n If anyone knowingly provides any information of a false, untrue, inaccurate or incomplete nature, " +
            "SHL will have sufficient grounds and rights to suspend or\n terminate the member in violation of this aspect of the Agreement, " +
            "and as such refuse any and all current or future use of SHL Services, or any portion\n " +
            "thereof.\n </p>";
        myHtmlText += "<p>\nIt is SHL's priority to ensure the safety and privacy of all its visitors, users and members, " +
            "especially that of children. Therefore, it is for this reason\n  that the parents of any child under the age of 18 " +
            "that permit their child or children access to the SHL website platform Services must create a \"family\"\n " +
            "account, which will certify that the individual creating the \"family\" account is of 18 years of age and as such, " +
            "the parent or legal guardian of any child\n or children registered under the \"family\" account. As the creator of the " +
            "\"family\" account, s/he is thereby granting permission for his/her child or\n children to access the various Services provided, " +
            "including, but not limited to, message boards, email, and/or instant messaging. It is the parent's and/or\n legal " +
            "guardian's responsibility to determine whether any of the Services and/or content provided are age-appropriate for his/her child.\n</p>";



        myHtmlText += ..... there are more characters in between, I can't add them all because of the character limit in stackoverflow




        myHtmlText += "<p> " +
            "Should you intend to create or to join any service, receive or request any such news, messages, " +
            "alerts or other information from our Services concerning healthcare, treatment, devices, companies, stock " +
            "quotes, investments or securities, please review the above Sections Warranty Disclaimers and Limitations of Liability again. In addition, for this " +
            "</p>";




        return myHtmlText;
    }

到目前为止一切正常。

现在,如果我只向myHtmlText添加一个单词,(In addition, for this particalur "</p>")标签文本将变为不可见。虽然标签边框是可见的。是否有一些最大内容大小?我搜索的时候找不到任何关于它的东西。

我在这里做错了什么?任何帮助表示赞赏...

1 个答案:

答案 0 :(得分:0)

您需要在启用滚动和禁用可编辑/选定功能的情况下使用UITextView(而不是UIScrollView和Content视图以及UILabel)。