我创建了一个回购.在bitbucket上.现在我想将该repo连接到Xcode 9.所以我可以直接推送,拉取并完成Xcode中的所有git.
有没有办法做到这一点?
谢谢!!!
我正在尝试使用CLGeocoder().reverseGeocodeLocation.
它给了我国家名称、街道名称、州和许多其他东西,但没有城市。我的代码有什么问题吗?
这是我的代码:
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
let location = locations[0]
CLGeocoder().reverseGeocodeLocation(location) { (placeMark, error) in
if error != nil{
print("Some errors: \(String(describing: error?.localizedDescription))")
}else{
if let place = placeMark?[0]{
print("country: \(place.administrativeArea)")
self.lblCurrentLocation.text = place.administrativeArea
}
}
} }
Run Code Online (Sandbox Code Playgroud)
我也使用下面的代码。但对我不起作用。这是另一种方式。
let geoCoder = CLGeocoder()
let location = CLLocation(latitude: (self.locationManager.location?.coordinate.latitude)!, longitude: (self.locationManager.location?.coordinate.longitude)!)
geoCoder.reverseGeocodeLocation(location, completionHandler: { (placemarks, error) -> Void in
// Place details
var placeMark: CLPlacemark!
placeMark = placemarks?[0]
// Address dictionary
print(placeMark.addressDictionary …Run Code Online (Sandbox Code Playgroud) 我的代码如下:
override func viewDidLoad() {
super.viewDidLoad()
textField.layer.cornerRadius = textField.frame.size.height / 2
textField.layer.borderWidth = 1.0
textField.layer.borderColor = UIColor(white: 0.5, alpha: 0.3).cgColor
textField.layer.shadowOpacity = 1
textField.layer.shadowRadius = 4.0
textField.layer.shadowColor = UIColor.black.cgColor
}
Run Code Online (Sandbox Code Playgroud)
但是,我认为有些东西丢失了...
提前致谢!
我只想UITableViewCell在第一次显示时动画一次。
我的代码:
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
cell.alpha = 0
let transform = CATransform3DTranslate(CATransform3DIdentity, 0, 200, 0)
cell.layer.transform = transform
UIView.animate(withDuration: 0.5, delay: 0, usingSpringWithDamping: 1, initialSpringVelocity: 1, options: .curveEaseOut, animations: {
cell.alpha = 1
cell.layer.transform = CATransform3DIdentity
})
}
Run Code Online (Sandbox Code Playgroud)
动画效果很好,但问题是,当用户向上滚动方向时,由于单元格被重用,动画也会被执行。这看起来不太好。
我想为每个单元格显示一次动画,我该如何实现?
它只显示相机的输出,但没有什么是幸福的.我不知道是什么问题.
我的代码是:
class QRScannerController: UIViewController, AVCaptureMetadataOutputObjectsDelegate {
var captureSession:AVCaptureSession?
var videoPreviewLayer:AVCaptureVideoPreviewLayer?
var qrCodeFrameView:UIView?
let supportedCodeTypes = [AVMetadataObject.ObjectType.qr]
var resultString = ""
override func viewDidLoad() {
super.viewDidLoad()
guard let captureDevice = AVCaptureDevice.default(for: AVMediaType.video) else {return}
do {
let input = try AVCaptureDeviceInput(device: captureDevice)
captureSession = AVCaptureSession()
captureSession?.addInput(input)
let captureMetadataOutput = AVCaptureMetadataOutput()
captureSession?.addOutput(captureMetadataOutput)
captureMetadataOutput.setMetadataObjectsDelegate(self, queue: DispatchQueue.main)
captureMetadataOutput.metadataObjectTypes = supportedCodeTypes
videoPreviewLayer = AVCaptureVideoPreviewLayer(session: captureSession!)
videoPreviewLayer?.videoGravity = AVLayerVideoGravity.resizeAspectFill
videoPreviewLayer?.frame = view.layer.bounds
view.layer.addSublayer(videoPreviewLayer!)
captureSession?.startRunning()
qrCodeFrameView = UIView()
if let qrCodeFrameView = qrCodeFrameView {
qrCodeFrameView.layer.borderColor = …Run Code Online (Sandbox Code Playgroud) 我试图将Swift 3代码转换为Swift 4.但是这个错误显示:
"substring(from :)'已弃用:请使用字符串切片下标和'partial range from'运算符."
我的代码是:
extension String {
func substring(_ from: Int) -> String {
return self.substring(from: self.characters.index(self.startIndex, offsetBy: from))
}
}
Run Code Online (Sandbox Code Playgroud) 我正在实现pod'Socket.IO-Client-Swift '
但在SocketEngine.swift文件中我收到此错误.
private func handleBase64(message: String) {
// binary in base64 string
let noPrefix = message[message.index(message.startIndex, offsetBy: 2)..<message.endIndex]
if let data = Data(base64Encoded: noPrefix, options: .ignoreUnknownCharacters) {
client?.parseEngineBinaryData(data)
}
}
Run Code Online (Sandbox Code Playgroud)
提前致谢!!
我做了一个能够切换自己的按钮,isEnabled它正在根据这个状态更新按钮的标题和图像.
myButton.setTitle("Enabled Title", for: .normal)
myButton.setImage(UIImage(named: "enabled_resource_name"), for: .normal)
myButton.setTitle("Disabled Title", for: .disabled)
myButton.setImage(nil, for: .disabled)
Run Code Online (Sandbox Code Playgroud)
在isEnabled我的按钮已经切换好.并且标题也根据那个改变了.但我发现了一个关于改变图像的奇怪问题.
在enabled以disabled情况下,图像UIImage(named: "enabled_resource_name")也不会被删除.
但它改变了一点.当它被禁用时,图像变得有点透明.而在disabled以enabled情况下,做做工精细.
为什么会这样?
当我没有收到通知时,我不想提出userId通知userInfo.
那么如何才能停止通知呢?
我试过的代码:
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void) {
print("willPresent notification")
let aps = notification.request.content.userInfo[AnyHashable("aps")]!
guard let data = aps as? [String: Any] else{ return}
if let userId = data["userId"] as? String {
completionHandler([.alert, .badge, .sound])
}else{
return
}
}
Run Code Online (Sandbox Code Playgroud)
但仍然会显示通知.
我想在我的APP中进行一些UI修改,其中包括Firebase存储.因此,出于临时目的,我想在Firebase中更改捆绑包标识符.有没有办法做到这一点?