小编Har*_*nda的帖子

IOS版本中的本地和推送通知兼容

我开发local NotificationsiOS 10.它工作得很好.但现在我应该如何编码local notifications,push notification如果用户正在使用iOS 9及以上版本.有人可以帮忙吗?

下面是代码 iOS 10

import UIKit
import UserNotifications

@available(iOS 10.0, *)
class ViewController: UIViewController,UNUserNotificationCenterDelegate {
    override func viewDidLoad() {
       super.viewDidLoad()

       if #available(iOS 10.0, *) {
        //Seeking permission of the user to display app notifications
        UNUserNotificationCenter.current().requestAuthorization(options: [.alert,.sound,.badge], completionHandler: {didAllow,Error in })
        UNUserNotificationCenter.current().delegate = self

       }
   }

   //To display notifications when app is running  inforeground
   func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> …
Run Code Online (Sandbox Code Playgroud)

apple-push-notifications ios uilocalnotification swift

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

缺少请求的请求令牌

从电话簿获取所有联系人并上传到服务器但出现以下错误。

在请求正文中附加图像时 FormData

在此处输入图片说明

试过的代码

传递文件 url 联系人缩略图路径

const path = con.thumbnailPath
body.append('image', {
     uri: path,
     type: 'image/jpeg',
     name: 'photo.jpg',
     type: 'multipart/form-data'
})
Run Code Online (Sandbox Code Playgroud)

试过的代码

传递没有“file://”的文件 url 联系人缩略图路径

const path = con.thumbnailPath.replace('file://', '')
body.append('image', {
     uri: path,
     type: 'image/jpeg',
     name: 'photo.jpg',
     type: 'multipart/form-data'
})
Run Code Online (Sandbox Code Playgroud)

试过的代码

使用检查文件是否存在于路径上 react-native-fs

if (con.thumbnailPath != '') {
     let isExist = RNFS.exists(con.thumbnailPath)
     if (isExist) {
         const path = con.thumbnailPath.replace('file://', '')
         console.log("Exist", path)
         body.append('image', {
             uri: path,
             type: 'image/jpeg',
             name: 'photo.jpg',
             type: 'multipart/form-data'
         })
     }
}
Run Code Online (Sandbox Code Playgroud)

要求

fetch(url, { …
Run Code Online (Sandbox Code Playgroud)

javascript multipartform-data request ios react-native

15
推荐指数
2
解决办法
7014
查看次数

使用 Apple 按钮登录 Apple 标志显得很小

苹果标志显得很小。我给 xib 中的 appleSignView 设置了 44px 的高度。

我正在使用的代码:

private func setupAppleSignIn() {
   let button = ASAuthorizationAppleIDButton(authorizationButtonType: .signIn, authorizationButtonStyle: .white)
   rootView.appleSignView.isHidden = false
   button.frame = rootView.appleSignView.bounds
   print(button.frame)
   rootView.appleSignView.addSubview(button)
   button.addTarget(self, action: #selector(handleAuthorizationAppleIDButtonPress), for: .touchUpInside)
}
Run Code Online (Sandbox Code Playgroud)

这是该按钮的默认行为还是我做错了什么? 截图在这里

ios swift ios13 apple-sign-in

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

实例化View Controller Swift 3 Tab Bar Controller

我如何选择标签栏控制器?标签上有2个视图控制器,其中包含导航控制器,标签栏控制器上有一个导航控制器。

let storyboard = UIStoryboard(name: "PendingOverview", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "PendingOverviewVC") as! PendingOverViewController
let nc = UINavigationController(rootViewController: vc)
self.present(nc, animated: false, completion: nil)
Run Code Online (Sandbox Code Playgroud)

谢谢

xcode storyboard uitabbarcontroller ios swift

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

iOS:dequeueReusableCell(withIdentifier:for :)和dequeueReusableCell(withIdentifier :)之间有什么区别?

根据官方文档,有两种方法可以从tableView的队列中获取可重用的单元.一个是dequeueReusableCell(withIdentifier:for:)另一个是dequeueReusableCell(withIdentifier:).假设从文档的解释,我认为前者是返回可重用单元格并将其添加到的方法tableView.另一方面,后者是仅返回可重用单元的方法.这是正确的吗?

如果是对的,我还有另外一个问题.

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
    let cell: UITableViewCell = self.tableView.dequeueReusableCell(with: SomeTableViewCell.self, for: indexPath)
    let anotherCell: UITableViewCell = self.tableView.dequeueReusableCell(with: AnotherTableViewCell.self)
    return anotherCell
}
Run Code Online (Sandbox Code Playgroud)

在第一行,我们可以获得可重用的单元格并添加celltableView.在第二个,我们只获得另一个可重复使用的单元格.最后,该方法返回从第二行获得的单元格.返回的单元格与已添加到tableView的单元格不同.在这种情况下,第一行添加到tableView的单元格将被最后一行返回的单元格替换?谢谢.

uitableview ios

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

如何用ARKit打开/ offf相机闪光灯?

我正在使用一个ARSCNView用于显示AR体验,用3D SceneKit内容增强相机视图.

ARSession共享管理设备摄像头的对象,但在ARSession 我找不到闪光灯的任何选项.

有没有办法打开/关闭相机闪光灯?

如何管理相机ARKit

如何正面和背面改变相机位置?

ios swift arkit

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