我有两个问题:
let amount:String? = amountTF.text
Run Code Online (Sandbox Code Playgroud)
amount?.characters.count <= 0它给出了错误:
Binary operator '<=' cannot be applied to operands of type 'String.CharacterView.IndexDistance?' (aka 'Optional<Int>') and 'In
Run Code Online (Sandbox Code Playgroud)
let am = Double(amount)它给出了错误:
Cannot invoke initializer for type 'Double' with an argument list of type '(String?)'
Run Code Online (Sandbox Code Playgroud)
我不知道如何解决这个问题.
我看到了一个改变导航栏高度的解决方案.但没有什么对我有用.现在我的应用程序有一个与导航控制器连接的视图控制器.我还没有在我的项目中实现任何其他代码.在开始我的项目之前,我需要更改导航栏的高度.
编辑:
.H:
- (CGSize)sizeThatFits:(CGSize)size ;
Run Code Online (Sandbox Code Playgroud)
.M:
@implementation UINavigationBar (customNav)
- (CGSize)sizeThatFits:(CGSize)size {
CGSize newSize = CGSizeMake(370,40);
return newSize;
}
@end
Run Code Online (Sandbox Code Playgroud) 我将我的应用程序提交到应用程序商店,他们说应用程序启动时崩溃。但对于我的设备和模拟器来说,它工作正常。无法找到这里的问题。
我附上了苹果给我的带有崩溃文件的二进制图像。请让我知道任何能够解决该问题的人。
谢谢
崩溃显示在这里:
Thread 0 name: Dispatch queue: com.apple.main-thread
Thread 0 Crashed:
0 WCi 0x0000000100df0454 specialized closure #1 in MainScreenViewController.getAdressName(coords:) + 509012 (MainScreenViewController.swift:668)
1 WCi 0x0000000100e01ed4 partial apply for closure #1 in MainScreenViewController.getAdressName(coords:) + 581332 (MainScreenViewController.swift:0)
2 WCi 0x0000000100de0288 _T0SaySo11CLPlacemarkCGSgs5Error_pSgIegxx_So7NSArrayCSgSo7NSErrorCSgIeyByy_TR + 443016 (MainScreenViewController.swift:0)
3 libdispatch.dylib 0x00000001d96596c8 0x1d95f9000 + 394952
4 libdispatch.dylib 0x00000001d965a484 0x1d95f9000 + 398468
5 libdispatch.dylib 0x00000001d96069a4 0x1d95f9000 + 55716
6 CoreFoundation 0x00000001d9bb0df4 0x1d9b05000 + 703988
7 CoreFoundation 0x00000001d9babcbc 0x1d9b05000 + 683196
8 CoreFoundation 0x00000001d9bab1f0 0x1d9b05000 + …Run Code Online (Sandbox Code Playgroud) 如果用户拒绝相机访问,我将显示一个带有取消和设置按钮的警报以显示它。但代码不起作用。
@IBAction func ProfileImageButton(_ sender: UIButton) {
print("profile image Button is pressed")
let imagePickerController = UIImagePickerController()
imagePickerController.delegate = self
profileimgbool = true
let actionSheet = UIAlertController(title: "Photo Source", message: "choose a Source", preferredStyle: .actionSheet)
actionSheet.addAction(UIAlertAction(title: "Camera", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .camera
self.present(imagePickerController, animated: true, completion: nil)
}))
actionSheet.addAction(UIAlertAction(title: "Photo Library", style: .default, handler: {(action:UIAlertAction) in imagePickerController.sourceType = .photoLibrary
self.present(imagePickerController, animated: true, completion: nil)}))
actionSheet.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: nil))
self.present(actionSheet, animated: true, completion: nil)
}
func checkCameraPermission() …Run Code Online (Sandbox Code Playgroud)