【发布时间】:2016-12-20 09:36:49
【问题描述】:
我在模拟器上正常运行这个应用程序,但是当我在实际设备上尝试它时它崩溃了,但与大多数断点不同的是,没有消息只是“与设备的连接丢失”弹出窗口。每次我在设备上运行它时都会发生这种情况,但从不在模拟器中运行。不是连接线的问题。
我有很多代码,但重要的是:
print("Test-1")
let imageView2 = uiview
// Find the path where to
save
guard let myFilePath = createMyFilePath(forFileName: "Page1test.png") else {
print("Cannot generate file path ☹️")
exit(0)
}
// Use this to check in finder where your file is saved
print(myFilePath)
print("Test")
// Transform the imageView in UIImage to save it
let imageToSave = createImage(fromView: imageView2)
// Get the image as data
guard let imageToSaveAsData = UIImagePNGRepresentation(imageToSave) else {
print("Cannot transform image to data ☹️")
exit(1)
}
// Save to Disk!
do{
try imageToSaveAsData.writeToFile(myFilePath, options: .DataWritingAtomic)
} catch {
print("Error, cannot write to the location \(myFilePath)")
}
// Load from Disk!
let loadedImageData = NSData(contentsOfFile: myFilePath)
// Check the data is the same
if loadedImageData == imageToSaveAsData {
print("✌️")
}
// Have a look at the loaded image!
var bob = UIImage(data: loadedImageData!)
imageviewloaded.image = bob
//Page 2
let imageViewtest = uiview2
// Find the path where to save
guard let myFilePathtest = createMyFilePath(forFileName: "Page2test.png") else {
print("Cannot generate file path ☹️")
exit(0)
}
// Use this to check in finder where your file is saved
print(myFilePathtest)
// Transform the imageView in UIImage to save it
let imageToSavetest = createImage(fromView: imageViewtest)
// Get the image as data
guard let imageToSaveAsDatatest = UIImagePNGRepresentation(imageToSavetest) else {
print("Cannot transform image to data ☹️")
exit(1)
}
// Save to Disk!
do{
try imageToSaveAsDatatest.writeToFile(myFilePathtest, options: .DataWritingAtomic)
} catch {
print("Error, cannot write to the location \(myFilePath)")
}
// Load from Disk! Page 2
let loadedImageDatatest = NSData(contentsOfFile: myFilePathtest)
// Check the data is the same
if loadedImageDatatest == imageToSaveAsDatatest {
print("✌️")
}
// Have a look at the loaded image!
var bobtest = UIImage(data: loadedImageDatatest!)
var imagecool = UIImageView()
imagecool.image = bobtest
//Page 4
let imageViewPage4 = uiview3
// Find the path where to save
guard let myFilePathPage4 = createMyFilePath(forFileName: "Page4test.png") else {
print("Cannot generate file path ☹️")
exit(0)
}
// Use this to check in finder where your file is saved
print(myFilePathtest)
// Transform the imageView in UIImage to save it
let imageToSavePage4 = createImage(fromView: imageViewPage4)
// Get the image as data
guard let imageToSaveAsDataPage4 = UIImagePNGRepresentation(imageToSavePage4) else {
print("Cannot transform image to data ☹️")
exit(1)
}
// Save to Disk!
do{
try imageToSaveAsDataPage4.writeToFile(myFilePathPage4, options: .DataWritingAtomic)
} catch {
print("Error, cannot write to the location \(myFilePath)")
}
// Load from Disk! Page 4
let loadedImageDataPage4 = NSData(contentsOfFile: myFilePathPage4)
// Check the data is the same
if loadedImageDataPage4 == imageToSaveAsDataPage4 {
print("✌️")
}
// Have a look at the loaded image!
var bobPage4 = UIImage(data: loadedImageDataPage4!)
var imagepage4 = UIImageView()
imagepage4.image = bobPage4
print("Test--2")
我在控制台中得到一个打印输出:
我不知道发生了什么。有人可以帮忙吗?
【问题讨论】:
标签: ios objective-c swift xcode breakpoints