小编Swi*_*yJD的帖子

如何在Swift中切换UITextField安全文本条目(隐藏密码)?

我当前有一个UITextfield带有眼睛图标的按钮,当按下时应该打开和关闭安全文本条目.

安全的文本输入

我知道您可以在属性检查器中选中"安全文本输入"框,但是如何操作它以便在按下图标时切换?

uitextfield ios swift

45
推荐指数
8
解决办法
5万
查看次数

- 使用`$(inherited)`标志,或 - 从目标中删除构建设置.CocoaPod Swift3 pod更新错误

在将Switf2项目更新到Swift3后更新cocoapods时,我在终端遇到了一些奇怪的错误.以下是错误:

[!] The `MyShowGuide [Debug]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-MyShowGuide/Pods-MyShowGuide.debug.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.

[!] The `MyShowGuide [Release]` target overrides the `FRAMEWORK_SEARCH_PATHS` build setting defined in `Pods/Target Support Files/Pods-MyShowGuide/Pods-MyShowGuide.release.xcconfig'. This can lead to problems with the CocoaPods installation
    - Use the `$(inherited)` flag, or
    - Remove the build settings from the target.
Run Code Online (Sandbox Code Playgroud)

到目前为止,我已经尝试了许多方法来尝试解决问题,包括删除派生数据和运行pod deintegrate/ …

xcode ios cocoapods swift

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

CABasicAnimation的完整Keyp​​ath列表是什么?

我查看了文档,但是我注意到它丢失了一些像"transform.scale.xy":[CoreAnimation Guide] [1]是否有更完整的列表?

core-animation

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

如何在Swift中使用一个IBAction用于多个按钮?

我有多个按钮,每个按钮都能切换应用程序的语言.而不是必须为每个按钮创建多个IBAction是否有一种方法可以将它们全部连接到一个IBAction并根据按下的按钮更改语言?我认为在这种情况下使用switch语句会很好,但不能确定如何设置它.

iphone uibutton ios swift

11
推荐指数
3
解决办法
3万
查看次数

如何在Swift中以编程方式更改Facebook按钮的文本?

我有他们SDK的facebook登录按钮,想要更改文本.我试过这段代码:

facebookButton.setTitle("my text here", forState: .Normal)
Run Code Online (Sandbox Code Playgroud)

但它不起作用.有办法吗?

这是facebook登录按钮代码的样子:

//MARK: Facebook Login

  func loginButton(loginButton: FBSDKLoginButton!, didCompleteWithResult result: FBSDKLoginManagerLoginResult!, error: NSError!) {
    if error == nil {

      facebookAPILogin(FBSDKAccessToken.currentAccessToken().tokenString, completionHandler: { error in

        if error == nil {

          self.performSegueWithIdentifier("loginToHomeSegue", sender: self)

        } else {



          self.showAlertWithTitle("Sorry".localized(), message: "There was a problem connecting with Facebook".localized() )

          print(error)

        }
        }
      )

    } else {

      showAlertWithTitle("Sorry".localized(), message: "There was a problem connecting with Facebook".localized() )

      print(error.localizedDescription)

    }
  }


  //Facebook Logout

  func loginButtonDidLogOut(loginButton: FBSDKLoginButton!) {
    print("User logged out") …
Run Code Online (Sandbox Code Playgroud)

facebook-graph-api ios facebook-ios-sdk swift

6
推荐指数
2
解决办法
4496
查看次数

iOS 10推送通知 - willPresentNotification和didReceiveNotificationResponse如何工作?

目前我的应用程序已设置为在ios 9中接收推送通知,它可以完美地工作但是在iOS 10中我没有收到它们.我查看了stackoverflow上的各种响应,并发现了这个:

推送通知未在iOS 10上收到,但在iOS 9及更早版本上运行

这似乎适用于海报.我不完全确定我应该在willPresentNotification和didReceiveNotificationResponse部分添加什么代码.如果有人有任何关于这些部分如何工作的例子,将不胜感激.这是我到目前为止处理推送通知的相关代码:

import UserNotifications
import Whisper

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {

func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {

  registerForPushNotifications(application)
}

 //MARK: Push Notification Settings
  func registerForPushNotifications(application: UIApplication) {

    //check to see if phone is updated to iOS 10
    if #available(iOS 10.0, *){
      UNUserNotificationCenter.currentNotificationCenter().delegate = self
      UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions([.Badge, .Sound, .Alert], completionHandler: {(granted, error) in
        if (granted)
        {
          UIApplication.sharedApplication().registerForRemoteNotifications()
        }
        else{
          print("registering for push notifications unsuccessful")
        }
      })
    }

    else{ //If user is …
Run Code Online (Sandbox Code Playgroud)

push-notification apple-push-notifications ios swift ios10

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

致命错误:Dictionary <String,Any>不符合Decodable,因为Any不符合Decodable

我正在尝试使用swift 4来解析本地json文件:

{
    "success": true,
    "lastId": null,
    "hasMore": false,
    "foundEndpoint": "https://endpoint",
    "error": null
}
Run Code Online (Sandbox Code Playgroud)

这是我正在使用的功能:

    func loadLocalJSON() {

        if let path = Bundle.main.path(forResource: "localJSON", ofType: "json") {
            let url = URL(fileURLWithPath: path)

            do {
                let data  = try Data(contentsOf: url)
                let colors = try JSONDecoder().decode([String: Any].self, from: data)
                print(colors)
            }
            catch { print("Local JSON not loaded")}
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但我一直收到错误:

致命错误:Dictionary不符合Decodable,因为Any不符合Decodable.

我尝试在此stackoverflow页面上使用"AnyDecodable"方法:如何在Swift 4可解码协议中解码具有JSON字典类型的属性, 但它跳转到'catch'语句: catch { print("Local JSON not loaded")使用时.有谁知道如何在Swift 4中解析这个JSON数据?

json ios swift swift4 decodable

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

如何在ObjectMapper中映射JSON词典?

我有看起来像这样的json数据:

{
  "balance": {
    "pointsEarned": 3,
    "pointsAvailable": 3,
    "pointsOnHold": 0,
    "pointsConsumed": 0,
    "nextReward": 6
  }
}
Run Code Online (Sandbox Code Playgroud)

我正在尝试映射“余额”,以便可以获取其他值:

class AccountBalance: Mappable {

  var balance: Dictionary<String, AnyObject>?
   var pointsAvailable: Int?

  required init?(_ map: Map) {

  }

  func mapping(map: Map) {

    balance <- map["balance.value"]
    pointsAvailable <- map ["pointsAvailable"]
  }
}
Run Code Online (Sandbox Code Playgroud)

根据objectMapper github页面,它是这样完成的:

ObjectMapper支持键内的点表示法,以便轻松映射嵌套对象。给定以下JSON字符串:

"distance" : {
     "text" : "102 ft",
     "value" : 31
}
Run Code Online (Sandbox Code Playgroud)

您可以按以下方式访问嵌套对象:

func mapping(map: Map) {
    distance <- map["distance.value"]
}
Run Code Online (Sandbox Code Playgroud)

每当我尝试访问“余额”时,都会得到零。知道我做错了什么吗?

ios swift alamofire objectmapper

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

如何创建自定义的“水平翻转”推送模式,如用于模式搜索的模式?

我正在尝试实现类似于以下内容:

翻转

但在导航控制器内部具有推送功能。有没有办法做到这一点?

uinavigationcontroller ios segue swift

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

使用CGAffineTransform swift 3语法使按钮逆时针旋转?

我试图让一个按钮逆时针旋转,但由于一些奇怪的原因它顺时针旋转.我知道以前的方法是通过M_PI但它已被弃用swift 3并替换为CGFloat.pi.我试过了:

   self.loginButton.transform = CGAffineTransform(rotationAngle: -CGFloat.pi)
Run Code Online (Sandbox Code Playgroud)

但它仍然顺时针移动.知道逆时针移动的语法是什么?

cgaffinetransform uiviewanimation ios swift

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