我添加了一些新设备.如何刷新配置文件,因为Xcode 8会自动管理签名资产?
我发现了这个问题:刷新由Xcode 7管理的团队配置文件中的设备? - 但我们不能在Xcode 8.3中这样做.
我没有设备,所以我手动将其添加到门户网站,并编辑了配置文件,但Xcode没有重新下载.
编译器错误Closure use of non-escaping parameter 'completion' may allow it to escape,这是有道理的,因为它将在函数返回后调用.
func sync(completion:(()->())) {
self.remoteConfig.fetch(withExpirationDuration: TimeInterval(expirationDuration)) { (status, error) -> Void in
completion()
}
}
Run Code Online (Sandbox Code Playgroud)
但如果我使闭包可选,那么没有编译错误,为什么呢?函数返回后仍然可以调用闭包.
func sync(completion:(()->())?) {
self.remoteConfig.fetch(withExpirationDuration: TimeInterval(expirationDuration)) { (status, error) -> Void in
completion?()
}
}
Run Code Online (Sandbox Code Playgroud) 我不是在后台处理推送通知.
对于以下步骤中的处理推送通知: -
UNUserNotificationCenter.App In Foreground然后推送通知工作正常并且在方法调用之下:
userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler
Run Code Online (Sandbox Code Playgroud)但我的问题是app在后台然后没有调用任何方法.所以任何人有想法或解决方案的背景为ios 10处理推送通知然后请帮助我.
谢谢.
带有字符串和侦听器(类似于swift中的闭包)参数的kotlin方法.
fun testA(str: String, listner: (lstr: String) -> Void) {
}
Run Code Online (Sandbox Code Playgroud)
像这样称呼它.
testA("hello") { lstr ->
print(lstr)
}
Run Code Online (Sandbox Code Playgroud)
错误:类型不匹配推断类型为单位但预期为Void
什么是单位?闭包的返回类型是Void.阅读很多其他问题,但可以通过这个简单的方法找到这里发生的事情.
我有一个应用程序以编程方式执行所有UI而不使用自动布局或任何类型的约束.在屏幕的底部是一个UIToolbar.我试图将其与iPhone X屏幕的底部安全区域配合使用,但由于VC的设计,我无法使用布局限制.
所以在我的layoutSubviews回调我这样做:
if (@available(iOS 11.0, *)) {
toolbarHeight += UIApplication.sharedApplication.keyWindow.safeAreaInsets.bottom;
}
Run Code Online (Sandbox Code Playgroud)
然后直接使用toolBarHeight设置UIToolbar的框架.
这是因为工具栏现在是正确的高度,并在旋转到横向时调整,但问题是工具栏的按钮不是顶部对齐,而是垂直居中.我无法弄清楚如何设置contentInsets或某种方式来顶部对齐UIToolbar按钮而不使用约束.
有任何想法吗?
我想在导航栏上应用渐变颜色。我应用了,但是状态栏颜色没有改变。谁能帮我这个?
以下是用于实现渐变颜色的代码:
let colorTop = UIColor(red: 69/255, green: 90/255, blue: 195/255, alpha: 1.0).CGColor
let colorBottom = UIColor(red: 230/255, green: 44/255, blue: 75/255, alpha: 1.0).CGColor
let gradientLayer = CAGradientLayer()
gradientLayer.colors = [ colorTop, colorBottom]
gradientLayer.locations = [ 0.0, 1.0]
gradientLayer.frame = CGRectMake(0, 0, 375, 64)
self.navigationController?.navigationBar.layer.addSublayer(gradientLayer)
Run Code Online (Sandbox Code Playgroud) 我已经在我的项目中集成了MKMapView但是当我弹出那个控制器时它无法释放内存.我在iOS 10中遇到这个问题,我只在iOS 9中测试过它运行正常.
我尝试用下面的代码释放内存,但它不起作用.
let overlays = self.mapView.overlays
self.mapView.removeOverlays(overlays)
self.mapView.mapType = MKMapType.standard
self.mapView.showsUserLocation = false
self.mapView.removeAnnotations(self.containerView.mapView.annotations)
self.mapView.delegate = nil
self.mapView.removeFromSuperview()
self.mapView = nil
Run Code Online (Sandbox Code Playgroud) 我使用 Android Studio Kotlin 插件转换了我的 Java Activity 类。 Android Studio > Code > 'Converting Java code to Kotlin'
我收到此错误。
错误:(109, 19) 'protected (in Fragment)' 属性公开了它的 'private' 类型 ExpiresLayout
代码
protected val mExpiresLayout = ExpiresLayout.NORMAL
Run Code Online (Sandbox Code Playgroud)
任何的想法?谢谢
在 IOS14 中,为了使用Advertising Identifier您需要请求许可,但是 AppStore 上已经可用的应用程序的行为是什么(使用 IOS13 SDK 编译)?
我已将设备更新到 IOS14 Beta 4 并从 AppStore 下载了应用程序。打开应用程序后,它不会自动要求任何跟踪权限,Advertising Identifier而是00000-0000-0000.
这是否意味着我必须提交使用 IOS14 SDK 编译的应用程序更新并请求跟踪许可,否则Advertising Identifier将不可用?
如何设置Text视图以多行显示文本?默认情况下是1行。
struct ContentView : View {
var body: some View {
Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. Suspendisse est leo, vehicula eu eleifend non, auctor ut arcu")
}
}
Run Code Online (Sandbox Code Playgroud)
我需要删除字符串中的所有数字,但我的代码是swift 2.3
let string = (string.componentsSeparatedByCharactersInSet(NSCharacterSet.decimalDigitCharacterSet()) as NSArray).componentsJoinedByString("")
Run Code Online (Sandbox Code Playgroud)
我如何在swift 3中做同样的事情?谢谢!