2016-05-03 23 views
-2

My image2つの段落の間の空白を削除するにはどうすればよいですか?

私はHTMLからテキストにデータを取得しています。 2段落間のスペースを避ける方法を教えてください。

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]を使用すると、HTMLコンテンツを受信した場合、あなたはNSAttributedStringを使用してUITextViewでそれを表示することができます

  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

あなたは投稿できますあなたのコード? – Shashikala

答えて

1

を.content:

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 
関連する問題