在将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/ …
我查看了文档,但是我注意到它丢失了一些像"transform.scale.xy":[CoreAnimation Guide] [1]是否有更完整的列表?
我有多个按钮,每个按钮都能切换应用程序的语言.而不是必须为每个按钮创建多个IBAction是否有一种方法可以将它们全部连接到一个IBAction并根据按下的按钮更改语言?我认为在这种情况下使用switch语句会很好,但不能确定如何设置它.
我有他们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) 目前我的应用程序已设置为在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) 我正在尝试使用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数据:
{
"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)
每当我尝试访问“余额”时,都会得到零。知道我做错了什么吗?
我试图让一个按钮逆时针旋转,但由于一些奇怪的原因它顺时针旋转.我知道以前的方法是通过M_PI
但它已被弃用swift 3并替换为CGFloat.pi
.我试过了:
self.loginButton.transform = CGAffineTransform(rotationAngle: -CGFloat.pi)
Run Code Online (Sandbox Code Playgroud)
但它仍然顺时针移动.知道逆时针移动的语法是什么?