小编iam*_*rak的帖子

Swift - 如何使用XIB文件创建自定义viewForHeaderInSection?

我可以在编程上创建简单的自定义viewForHeaderInSection,如下所示.但是我想要做更复杂的事情,可能是与不同​​类的连接,并像tableView单元一样到达它们的属性.简单地说,我想看看我做了什么.

func tableView(tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {

    if(section == 0) {

        let view = UIView() // The width will be the same as the cell, and the height should be set in tableView:heightForRowAtIndexPath:
        let label = UILabel()
        let button   = UIButton(type: UIButtonType.System)

        label.text="My Details"
        button.setTitle("Test Title", forState: .Normal)
        // button.addTarget(self, action: Selector("visibleRow:"), forControlEvents:.TouchUpInside)

        view.addSubview(label)
        view.addSubview(button)

        label.translatesAutoresizingMaskIntoConstraints = false
        button.translatesAutoresizingMaskIntoConstraints = false

        let views = ["label": label, "button": button, "view": view]

        let horizontallayoutContraints = NSLayoutConstraint.constraintsWithVisualFormat("H:|-10-[label]-60-[button]-10-|", options: .AlignAllCenterY, metrics: …
Run Code Online (Sandbox Code Playgroud)

uitableview xib ios swift

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

Xcode 8.3版本中的Apple Mach -O Linker(Id)警告

我刚刚将我的Xcode更新为8.3版本.

而现在我收到许多警告,例如:"指针未对齐地址......"来自我的豆荚.

在此输入图像描述

我看到FirebaseAnalyticsFirebaseCore pod会触发此问题.

在这种情况下我该怎么办?

现在修复了'pod update'.

xcode ios firebase firebase-analytics xcode8

32
推荐指数
0
解决办法
910
查看次数

XCode"DTAssetProviderService无法启动.."错误,如何修复此问题?

我已经升级了macOS Sierra Developer Preview,但是我的XCode 7.3.1在尝试在模拟器上运行我的项目时给出了以下错误.另外Generic to archieve给出了另一个错误:

除存档外:还发生了加密验证失败.

在此输入图像描述

我试图在stackoverflow上解决许多类似的主题答案,但没有帮助我.我怎样才能解决这个问题?

我在XCode 8.0 Beta之前尝试过,卸载它删除derivedData并重置内容模拟器,但仍然会出现此错误.

更新:

我想分享想要现在使用Sierra的信息.如果您决定进行以下更改,则需要知道Apple不允许"使用测试版软件上传App Store".继续使用El Capitan和XCode 7.3.1进行生产.

xcode ios ios-simulator

15
推荐指数
3
解决办法
4559
查看次数

如何发布One Signal通知的附加数据并接收该数据?

我检查了OneSignal文档但我无法理解为初学者如何在iOS Native SDK中使用Swift来设置字典作为发布通知的附加数据(如postID,userID,类型)来决定并在用户与通知交互时重定向.

对于发布我只是这样做:

 OneSignal.sendTag("username", value: "\(user)")
 OneSignal.postNotification(["contents": ["en": "@\(user) added an additive to your '\(title)' experience: \"\(strLast)\""],
                                                                "include_player_ids": [postOwnerPlayerID],
Run Code Online (Sandbox Code Playgroud)

接收:

 OneSignal.initWithLaunchOptions(launchOptions, appId: "______", handleNotificationReceived: nil, handleNotificationAction: {
        (result) in

        // This block gets called when the user reacts to a notification received
        let payload = result?.notification.payload

        //Try to fetch the action selected
        if let additionalData = payload?.additionalData {

            print("payload")
            print(additionalData)
        }

        // After deciding which action then I can redirect user..

        let username: String? = UserDefaults.standard.string(forKey: KEY_UID)

        if username …
Run Code Online (Sandbox Code Playgroud)

push-notification ios swift onesignal

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

在 Xcode 12.4 中找不到框架 FIRAnalyticsConnector

在 Xcode 12.4 中的 pod 更新后出现“未找到框架 FIRAnalyticsConnector”错误。我已经清理并重建了项目,但它留在那里。我该怎么办?

xcode ios firebase firebase-authentication

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

未找到框架 GoogleDataTransportCCTSupport

我在pod update. 我尝试了许多干净的构建文件夹和项目。但它仍然留在那里。我该怎么办?

xcode ios firebase

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

Firebase存储,基于用户的上传/删除的正确规则是什么?

我想为Firebase/Storage创建基于用户的安全性.如果我只上传图像,下面允许写入很好.但它可以防止删除照片.如何为此案例创建适当的安全规则?

service firebase.storage {
  match /b/<bucket>/o {
    match /{allPaths=**} {
      allow read: if request.auth != null;
    }
    match /users/{uid}/{filename} {
      allow write: if isCurrentUser(uid);
      allow write: if isImage() &&
                      isCurrentUser(uid) &&
                      lessThanNMegabytes(n) &&
                      request.resource !=null &&
                      filename.size() < 50;
    }
  }
}

function isCurrentUser(uid) {
    return request.auth.uid == uid;
}

function lessThanNMegabytes(n) {
    return request.resource.size < n * 1024 * 1024;
}

function isImage() {
    return request.resource.contentType.matches("image/.*");
}
Run Code Online (Sandbox Code Playgroud)

firebase firebase-security firebase-storage

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

One Signal - idsAvailable已弃用

OneSignal的最新版本版本会生成一个警告,例如' idsAvailable '已被弃用.如何使用getPermissionSubscriptionState()代替idsAvailable 获取'playerID',如下所示?

    OneSignal.idsAvailable({ (userId, pushToken) in

        if (pushToken != nil) {

            if let playerID = userId {

                // do something

            }
        }
    })
Run Code Online (Sandbox Code Playgroud)

ios swift onesignal

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

Sprite Kit-有时球从屏幕上消失了吗?

在此处输入图片说明

我是Sprite Kit的新手。我尝试了2个球员进行简单的弹跳游戏,另一个是缓慢跟踪球。但是我发现了一个问题。当我将线移到带边缘的球上时,球从屏幕上消失了。还有一次没问题,球跳动。问题是什么?

我有一个GameScene,sks和ViewController。我的精灵节点来自sks。如果有人解释这种情况。会更好。我已附上我在下面所做的工作。

我的GameScene:

class GameScene: SKScene {

var ball = SKSpriteNode()
var enemy = SKSpriteNode()
var main = SKSpriteNode()

override func didMove(to view: SKView) {

    ball = self.childNode(withName: "ball") as! SKSpriteNode
    enemy = self.childNode(withName: "enemy") as! SKSpriteNode
    main = self.childNode(withName: "main") as! SKSpriteNode

    ball.physicsBody?.applyImpulse(CGVector(dx: -20, dy: -20))
    ball.physicsBody?.linearDamping = 0
    ball.physicsBody?.angularDamping = 0

    let border = SKPhysicsBody(edgeLoopFrom: self.frame)
    border.friction = 0
    border.restitution = 1

    self.physicsBody = border

}

override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {

    for touch …
Run Code Online (Sandbox Code Playgroud)

sprite-kit swift

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

Swift 3 - Firebase推送通知,我该怎么办?

我喜欢下面的Swift 2.但它在Swift 3中不起作用.我怎么能提供这个?如果有人解释这将是伟大的.

didFinishLaunchingWithOptions

let notificationSettings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
UIApplication.sharedApplication().registerUserNotificationSettings(notificationSettings)
application.registerForRemoteNotifications()
Run Code Online (Sandbox Code Playgroud)

func application(application: UIApplication, didRegisterUserNotificationSettings notificationSettings: UIUserNotificationSettings) {
    if notificationSettings.types != .None {
        application.registerForRemoteNotifications()
    }
}

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {

    print("Meesage ID \(userInfo["gcm_message_id"]!)")
    print(userInfo)

}
Run Code Online (Sandbox Code Playgroud)

我可以做简单的本地通知,但是我无法从Firebase远程推送通知.

我试过了

UNUserNotificationCenter.currentNotificationCenter().delegate = self

UNUserNotificationCenter.currentNotificationCenter().requestAuthorizationWithOptions([.Alert, .Badge, .Sound]) { (success, error:NSError?) in

        if success {
            print("Notification access true!")
            application.registerForRemoteNotifications()
        }
        else {
            print(error?.localizedDescription)
        }

}
Run Code Online (Sandbox Code Playgroud)

func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) { …
Run Code Online (Sandbox Code Playgroud)

ios firebase swift swift3 firebase-notifications

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