2016-05-03 11 views
-2

My imageWie Leerzeichen zwischen zwei Absätzen zu entfernen?

Ich bekomme Daten von Html zum Text. Jetzt bitte sagen Sie mir, wie man den Abstand zwischen zwei Absätzen vermeidet?

func processGetDescriptionResponse(json: JSON) { 
    let status = json.dictionaryObject!["status"] as? Bool 
    if status == true { 
     let data = json.dictionaryValue["data"]! 
     let values = data.arrayValue 
     dataSourceDescription.removeAll() 
     for i in 0 ..< values.count { 
      let description = Description.initWithJSON(values[i]) 
      dataSourceDescription.append(description) 

// DetailDescription.text = dataSourceDescription [i] .content

  if dataSourceDescription[i].file_url == "" 
      { 
       DetailImage.image = UIImage(named: "logo_two_fifty") 
      } 
      else 
      { 
      let imageURL = NSURL(string: baseURLString + dataSourceDescription[i].file_url!) 


      DetailImage.kf_setImageWithURL(imageURL!, placeholderImage: nil, optionsInfo: [.Transition(ImageTransition.Fade(50))]) { (image, error, cacheType, imageURL) in 
       } 

      } 


      DetailDescription.attributedText = convertText(dataSourceDescription[i].content!) 


      print(DetailDescription.text) 
     } 

    } else { 

    } 
} 
+0

Können Sie nach dein Code? – Shashikala

Antwort

1

Wenn Sie HTML-Inhalte erhalten, können Sie es in UITextView mit NSAttributedString anzuzeigen:

let htmlString = "<html><body><p>Para 1</p><p>Para 2</p></body></html>" 

let attributedString = try! 
    NSAttributedString(data: htmlString.dataUsingEncoding(NSUnicodeStringEncoding, allowLossyConversion: false)!, 
         options: [NSDocumentTypeDocumentAttribute: NSHTMLTextDocumentType], 
         documentAttributes: nil) 

yourTextView.attributedText = attributedString 
Verwandte Themen