2016-04-23 3 views
0
  1. Ich habe eine HMTL String wie folgt aus:

Kaiser Kaiser Meiji-Ära, die im Jahre 1868 an die Macht kam er das Recht akzeptiert zu regieren alle vollständig von der Warlord über < zur Verfügung gestellt - mehr -> und in dieser Zeit hat er b Suchen Sie das Empire of Japan zu stärken, stark zu sein ... < div> < img width = "624" height = "353" src = „https://www.pmhotnews.com/wp-content/ uploads/2016/04/B20-24-0416-16-624x353.jpg "class =" attachment-post-Miniaturbildgröße-post-Thumbnail-wp-post-image "alt =" B20-24-0416 (16) „/ > </div> < br /> [mehr] ➥ < i> Quelle von < strong> Volk </strong> - < a href = „https://www.pmhotnews.com/2016/04/23 /56901.html/ „target =“ _ blank „> Fotos selten Samurai von Japan in den 1800er Jahren, der den Namen des Islam gehört hatte Ich habe nicht </a gesehen> </i>wie Extrakt html String und es zu UILabel in Xcode hinzufügen Objective C mit?

  1. Ich habe ein UILabel wie folgt aus:

    UILabel * contentLabel = [[UILabel alloc] init]; 
    
  2. Wie kann ich Text contentLabel mit anklickbaren Ereignisse Objective-C-Code verwenden?

Antwort

0
contentLabel.text = @"ក្នុងសម័យ​អធិរាជ Emperor Meiji ដែល​ឡើងកាន់​អំណាច​ក្នុង​ឆ្នាំ ១៨៦៨ ព្រះអង្គ​បានទទួល​យក​សិទ្ធិ​គ្រប់គ្រង​ប្រទេស​ពេញលេញ ដែល​ផ្ដល់​ដោយ​ស្ដេចត្រាញ់​គ្រប់គ្នា​នៅ​ទូទាំងប្រទេស ហើយ​ក្នុង​គ្រា​នោះដែរ​ព្រះអង្គ​បាន​ខិតខំ​ពង្រឹង​អាណាចក្រ​ជប៉ុន​ឲ្យ​មាន​ភាពរឹងមាំ ...[more] ➥ប្រភពពីគេហទំព័រ ប្រជាប្រិយ - រូបថត​ដ៏​កម្រ​របស់​សាមូរ៉ៃ​ជប៉ុន​ក្នុង​កំលុង​ឆ្នាំ ១៨០០ ដែល​ធ្លាប់តែ​ឮឈ្មោះ​តែ​មិនដែល​បានឃើញ​​​"; 

Sie können tapgesture Erkennungs auf dem Etikett nehmen klicken handhaben

1
NSString * strHtmlString = @"Your HTML String"; 

NSAttributedString * strAttrib = [[NSAttributedString alloc] initWithData:[strHtmlString dataUsingEncoding:NSUnicodeStringEncoding] options:@{ NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType } documentAttributes:nil error:nil]; 

contentLabel.attributedText = strAttrib; 

Hope this kann Ihnen helfen :)