嗨我有一些代碼獲取座標和日期和時間,但它只顯示控制檯輸出窗口中的結果。有人能指導我找到最好的解決方案來在模擬器中顯示輸出。 tableview或我應該使用什麼。我基本上只需要一個開始打印到xcode模擬器
回答
那麼你可以添加一個標籤到你的視圖,並將標籤文本更改爲你想要打印的內容。
或
您可以顯示警報視圖並顯示要打印的內容。
下面是添加警報視圖的示例(發件人是調用此方法的視圖控制器)。
func showSimpleAlert(_ title:String, message:String, sender:AnyObject) {
let alertController = UIAlertController(title: title, message: message, preferredStyle: .alert)
let defaultAction = UIAlertAction(title: "OK", style: .default, handler: nil)
alertController.addAction(defaultAction)
sender.present(alertController, animated: true, completion: nil)
}
然後你只需要你想打印(日期,雙人間等),以一個String對象
編輯對象轉換:當你調用警報視圖,這裏是你可以做什麼:
// Assuming we're in the ViewController class
let alertString = String(format:"one: %@\ntwo: %@\nthree: %@\nfour: %@\nfive: %@",
Formatter.string(from: houses.one),
Formatter.string(from: houses.two),
Formatter.string(from: houses.three),
Formatter.string(from: houses.four),
Formatter.string(from: houses.five))
showSimpleAlert("Debug print", message: alertString, sender: self)
我已添加代碼並添加了打印命令,但在模擬器中什麼也看不到只是空白屏幕 – sabrefm1
您可以在您的問題中添加您的代碼嗎? – Jeremy
打印( 「一」,formatter.string(來自:houses.one)) 打印( 「二」,formatter.string(來自:houses.two)) 打印( 「三」,formatter.string(來自:房屋(「four」,formatter.string(from:houses.four)) print(「five」,formatter.string(from:houses.five)) 這些全部打印到控制檯輸出但打印希望看到他們在模擬器屏幕 – sabrefm1
有關打印日誌的詳細輸出,請使用開發者專用技巧。添加一個輕敲手勢(只有您自己知道),並且在2秒鐘內連續3次點擊該區域,應該從您的應用調用隱藏功能,在此顯示UITextView
中的所有日誌。您應該實現一個自定義記錄器類,將所需輸出記錄到應該用於調用日誌的純文本文件。
添加UILabel將影響您的應用程序的用戶界面,您可能不希望這些日誌可供所有用戶使用。因此,有一個隱藏的區域來檢查日誌將是一個優雅的方法。
其不是打印日誌,而是從我的代碼中得到的結果顯示在輸出窗口中。 – sabrefm1
- 1. 在模擬器上打印
- 2. 打印慢(模擬打字)
- 3. Xcode「模擬器」? Android Studio「模擬器」?
- 4. mac的pos打印機模擬器
- 5. iOS模擬器 - Xcode
- 6. 的iOS模擬器打印機錯誤 - 空氣打印
- 7. 在ZPL中模擬打印
- 8. 模擬SWT打印機
- 9. iOS模擬器和XCode模擬Compass?
- 10. 將iOS6.1模擬器添加到Xcode 6
- 11. 獲取BlackBerry模擬器打印到命令行/控制檯
- 12. 標籤沒有打印到ios模擬器目標c
- 13. 在ios中打印:如果打印機連接到mac,是否可以從模擬器打印?
- 14. 的Xcode 8.0模擬器破
- 15. Xcode 4.2.1。模擬器問題
- 16. Xcode 6.3 - 模擬器大小
- 17. Xcode ViewController和iOS模擬器
- 18. iOS模擬器(Xcode 4.2)
- 19. Xcode 9.0模擬器「消失」
- 20. 模擬器從Xcode消失
- 21. Xcode 8模擬器崩潰
- 22. 的Xcode - 模擬器 - pushnotification
- 23. Clean iOS模擬器/ XCode
- 24. Xcode中的iOS模擬器
- 25. Xcode和iPad模擬器
- 26. Xcode模擬器添加iphone5
- 27. Xcode模擬器刻度
- 28. iPhone4模擬器在XCode 4.0.2
- 29. Xcode無法在Xcode中的模擬器
- 30. iOS模擬器Xcode 7.1和Xcode 7.2
您可以使用標籤來顯示模擬器的屏幕上 –
一些文字'我基本上只需要一個start'。確實。以「hello world」爲例。它完全符合你的需求。 – Desdenova