3
我正在使用swift處理我的第一個iOS應用程序。我需要用Newline(\ n)在UILabel中顯示一些細節。它的工作很好,當我直接給像下面換行符( n)不能在swift中工作
myLabel.text = "\nSome \n\n Text here\n"
因爲我需要存儲的文字,我保存它作爲核心數據和檢索爲String。
let context: NSManagedObjectContext = appDel.managedObjectContext
let fetchRequest = NSFetchRequest()
let entityDescription = NSEntityDescription.entityForName("Details", inManagedObjectContext: context)
fetchRequest.entity = entityDescription
do {
let result = try context.executeFetchRequest(fetchRequest)
print(result.count)
if (result.count > 0) {
for i in 0..<result.count
{
let person = result[i] as! NSManagedObject
fee = person.valueForKey("fee") as! String
content = person.valueForKey("content") as! String
pattern = person.valueForKey("pattern") as! String
documentation = person.valueForKey("documentation") as! String
}
}
} catch {
let fetchError = error as NSError
print(fetchError)
}
但是,當我將費用設置爲標籤文本時,Newline不起作用。
myLabel.text = fee
我該怎麼做才能做到這一點?
在此先感謝。
myLabel.text =費用myLabel.text =「\\(費用)」。我認爲它應該工作..試試這個.. – Bhoomi
我試過了。但仍然沒有改善。 –
同樣的事情發生在我身上。它只是在普通文本中打印控制檯中的\ n。 –