小编Uda*_*iya的帖子

如何使用BitBucket配置Xcode 9

我创建了一个回购.在bitbucket上.现在我想将该repo连接到Xcode 9.所以我可以直接推送,拉取并完成Xcode中的所有git.

有没有办法做到这一点?

谢谢!!!

git xcode bitbucket ios xcode9

8
推荐指数
1
解决办法
4277
查看次数

无法快速获取当前纬度和经度的城市名称

我正在尝试使用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)

ios currentlocation clgeocoder swift

6
推荐指数
1
解决办法
4508
查看次数

如何在带有圆角的UITextField上添加阴影?

我想在UITextField圆角上实现阴影,如下图所示:在此处输入图片说明

我的代码如下:

    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)

但是,我认为有些东西丢失了...

输出: 在此处输入图片说明

提前致谢!

uitextfield ios swift

4
推荐指数
1
解决办法
2022
查看次数

UITableview Cell 动画只播放一次

我只想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)

动画效果很好,但问题是,当用户向上滚动方向时,由于单元格被重用,动画也会被执行。这看起来不太好。

我想为每个单元格显示一次动画,我该如何实现?

animation uitableview ios swift

4
推荐指数
1
解决办法
1068
查看次数

QRCode扫描仪在iOS 11中不起作用,仅显示相机预览

它只显示相机的输出,但没有什么是幸福的.我不知道是什么问题.

我的代码是:

    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)

qr-code ios avcapture swift swift4

3
推荐指数
1
解决办法
2651
查看次数

如何在Swift 4中使用String下标

我试图将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)

ios swift

2
推荐指数
1
解决办法
5881
查看次数

如果没有更多的上下文swift 4.0,表达式的类型是不明确的

我正在实现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)

在此输入图像描述

提前致谢!!

ios swift swift4

2
推荐指数
1
解决办法
1万
查看次数

图像未删除UIButton的禁用状态

我做了一个能够切换自己的按钮,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我的按钮已经切换好.并且标题也根据那个改变了.但我发现了一个关于改变图像的奇怪问题.

enableddisabled情况下,图像UIImage(named: "enabled_resource_name")也不会被删除.

但它改变了一点.当它被禁用时,图像变得有点透明.而在disabledenabled情况下,做做工精细.

为什么会这样?

uibutton swift

1
推荐指数
1
解决办法
404
查看次数

停止提交PushNotification

当我没有收到通知时,我不想提出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)

但仍然会显示通知.

apple-push-notifications ios swift

1
推荐指数
1
解决办法
74
查看次数

如何在Firebase中更改已发布应用的捆绑包标识符?

我想在我的APP中进行一些UI修改,其中包括Firebase存储.因此,出于临时目的,我想在Firebase中更改捆绑包标识符.有没有办法做到这一点?

android ios firebase swift firebase-storage

0
推荐指数
1
解决办法
1266
查看次数