0
私はこのアプリケーションを通常Simulatorで実行しますが、実際のデバイスで試したときにクラッシュしますが、ほとんどのブレークポイントとは異なり、 。それは私がデバイス上で実行するたびに起こりますが、シミュレータでは決して起こりません。接続線に問題はありません。デバイス上で実行するとブレークポイントはSwiftのシミュレータではない
私は、コードの多くを持っていますが、ここで重要なものです:
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")
私はコンソールでのプリントアウトを取得:
私が起こっていただきました見当がつかない。誰も助けることができますか?
私はどこに問題が発生しているのかを見つけました.2ページまたは4ページを保存しようとすると、私はどこにいるのでしょうか。何か案は? –