标签: ios13

如何在SwiftUI中设置TextField的键盘类型?

我似乎找不到任何信息,也找不到如何在SwiftUI的TextField上设置键盘类型的方法。能够启用安全文本属性,隐藏密码等也很好。

这篇文章显示了如何“包装” UITextField,但是如果不需要的话,我宁愿不使用任何UI控件。 如何使TextField成为第一响应者?

任何人都知道如何在不包装旧式UI控件的情况下完成此操作?

keyboard ios13 swiftui

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

iOS 13 Killing应用程序,因为它在收到PushKit VoIP回调后从未向系统发布来电

升级到iOS Beta 13之后,我注意到了一件不愉快的事情:我的应用有时会因传入的VoIP推送而崩溃。

在崩溃报告中,我看到以下内容:

iOS 13 Killing app because it never posted an incoming call to the system after receiving a PushKit VoIP callback 

Fatal Exception: NSInternalInconsistencyException
0  CoreFoundation                 0x1af21b9f0 __exceptionPreprocess
1  libobjc.A.dylib                0x1af7284fc objc_exception_throw
2  CoreFoundation                 0x1af11efec + 
 [_CFXNotificationTokenRegistration keyCallbacks]
3  Foundation                     0x1aeda1330 -[NSAssertionHandler 
 handleFailureInMethod:object:file:lineNumber:description:]
4  PushKit                        0x19caa6b54 -[PKPushRegistry 
 _terminateAppIfThereAreUnhandledVoIPPushes]
5  libdispatch.dylib              0x1afa441ec _dispatch_client_callout
6  libdispatch.dylib              0x1af9f6c6c 
_dispatch_lane_barrier_sync_invoke_and_complete
7  PushKit                        0x19caa5b74 __73-[PKPushRegistry 
 voipPayloadReceived:mustPostCall:withCompletionHandler:]_block_invoke
8  libdispatch.dylib              0x1afa43678 
 _dispatch_call_block_and_release
9  libdispatch.dylib              0x1afa441ec 
  _dispatch_client_callout

10 libdispatch.dylib              0x1af9f61f8 
_dispatch_main_queue_callback_4CF$VARIANT$mp
11 CoreFoundation                 0x1af1992a0 
CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE …
Run Code Online (Sandbox Code Playgroud)

voip apple-push-notifications pushkit callkit ios13

11
推荐指数
1
解决办法
5275
查看次数

SwiftUI ScrollView:如何修改.content.offset又名Paging?

问题

如何修改scrollView的滚动目标?我正在寻找一种替代“经典” scrollView委托方法的方法

override func scrollViewWillEndDragging(scrollView: UIScrollView, withVelocity velocity: CGPoint, targetContentOffset: UnsafeMutablePointer<CGPoint>)

......在这里我们可以modfify目标scrollView.contentOffset通过targetContentOffset.pointee例如创建一个自定义分页行为。

或者换句话说:我确实想在(水平)scrollView中创建分页效果。

我尝试过的就是 是这样的:

    ScrollView(.horizontal, showsIndicators: true, content: {
            HStack(alignment: VerticalAlignment.top, spacing: 0, content: {
                card(title: "1")
                card(title: "2")
                card(title: "3")
                card(title: "4")
            })
     })
    // 3.
     .content.offset(x: self.dragState.isDragging == true ? self.originalOffset : self.modifiedOffset, y: 0)
    // 4.
     .animation(self.dragState.isDragging == true ? nil : Animation.spring())
    // 5.
    .gesture(horizontalDragGest)
Run Code Online (Sandbox Code Playgroud)

尝试

这是我尝试过的方法(除了自定义的scrollView方法):

  1. scrollView的内容区域大于屏幕空间,因此根本无法滚动。

  2. 我创建了一个,DragGesture()以检测是否有阻力在继续。在.onChanged和.onEnded闭包中,我修改了@State值以创建所需的scrollTarget。

  3. 有条件地将原始未更改的值和新修改的值都馈送到.content.offset(x:y :)修饰符中-取决于dragState作为缺少的scrollDelegate方法的替代。

  4. 仅在拖动结束时才有条件地添加动画。

  5. 将手势附加到scrollView。

长话短说。没用 我希望我能解决我的问题。

有什么解决办法吗?期待任何投入。谢谢!

scrollview ios13 swiftui

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

在iOS 13中场景的UI状态恢复,同时仍支持iOS 12。

这有点长,但并不琐碎,需要花很多时间来证明这个问题。

我试图弄清楚如何将一个小示例应用程序从iOS 12更新到iOS13。该示例应用程序不使用任何故事板(除了启动屏幕)。这是一个简单的应用程序,显示了一个带有由计时器更新的标签的视图控制器。它使用状态恢复,因此计数器从中断处开始。我希望能够支持iOS 12和iOS13。在iOS 13中,我想更新到新的场景架构。

在iOS 12下,该应用程序可以正常运行。在全新安装中,计数器从0开始并上升。将应用程序置于后台,然后重新启动应用程序,然后计数器从停止处继续计数。状态恢复全部正常。

现在,我正在尝试使用场景在iOS 13下运行该功能。我遇到的问题是找出初始化场景窗口并将导航控制器和主视图控制器还原到场景的正确方法。

我已经阅读了尽可能多的Apple文档,这些文档与状态恢复和场景有关。我看过与窗口和场景相关的WWDC视频(212-在iPad上引入多个Windows258-为多个Windows架构应用)。但我似乎缺少将所有内容组合在一起的作品。

当我在iOS 13下运行该应用程序时,所有预期的委托方法(AppDelegate和SceneDelegate)都被调用。状态恢复正在恢复导航控制器和主视图控制器,但rootViewController由于所有UI状态恢复都在AppDelegate中,因此我不知道如何设置场景窗口的状态。

似乎也有一些与NSUserTask应该使用的相关的东西,但我无法说明问题。

缺少的部分似乎是在willConnectTo方法中SceneDelegate。我敢肯定,我还需要一些变化stateRestorationActivitySceneDelegate。中可能还需要进行更改AppDelegate。我怀疑其中的任何内容都ViewController需要更改。


要复制我的工作,请使用Single View App模板使用Xcode 11(当前为Beta 4)创建一个新的iOS项目。将部署目标设置为iOS 11或12。

删除主故事板。在Info.plist中删除对Main的两个引用(一个位于顶层,另一个位于Application Scene Manifest的深处。按如下所示更新3个swift文件。

AppDelegate.swift:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {
    var window: UIWindow?

    func application(_ application: UIApplication, willFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey : Any]? = nil) -> Bool {
        print("AppDelegate willFinishLaunchingWithOptions")

        // This probably shouldn't be run under iOS 13? …
Run Code Online (Sandbox Code Playgroud)

ios state-restoration ios13 uiscene

11
推荐指数
4
解决办法
6337
查看次数

iOS 13状态栏样式

我想在iOS 13上的每个ViewController级别上更改状态栏样式。到目前为止,我没有任何运气。
我在info.plist中定义UIUserInterfaceStyleLight(因为我不想支持暗模式),并设置UIViewControllerBasedStatusBarAppearancetruepreferredStatusBarStyle在我的ViewController上调用,但被完全忽略。在UIUserInterfaceStyle似乎永远覆盖VC偏好。如何在iOS 13上使用每个ViewController状态栏样式?还是不再支持?

ios uistatusbar swift ios13

11
推荐指数
2
解决办法
4774
查看次数

iOS 13.0 - Best approach for supporting Dark Mode and also support iOS 11 &amp; 12

So I've posted on Apple Developer Forums, but haven't gotten a reply yet.

Background:

iOS 13 has introduced Dark Mode and a number of System Colors with predefined Light and Dark variants: (https://developer.apple.com/videos/play/wwdc2019/214/)

These colors can be used in the storyboard directly as named colors. They've also been added as static colors to the UIColor class: (https://developer.apple.com/documentation/uikit/uicolor/ui_element_colors)

However, static colors added to UIColor are not available in code in iOS 11 and 12. This makes its …

uicolor ios uistoryboard swift ios13

11
推荐指数
1
解决办法
558
查看次数

UIViewController自定义过渡卡在iOS13上

我已经在我的iOS应用中实现了两个视图控制器之间的自定义过渡,并且在iOS 10、11和12上运行良好。

现在,我想使用Xcode 11 beta 6和iOS 13 beta 8为iOS 13做好准备,但是过渡很困难。

自定义过渡应将第一个视图控制器向上移动并移出屏幕,第二个视图控制器从下向上移出。但是现在它又回到了iOS13的默认呈现样式pageSheet,只是将第一个视图控制器缩小了一点,并添加了暗淡的叠加层。但是第二个视图没有出现。

我发现,在该方法animatePresentation(context: UIViewControllerContextTransitioning)context不“从”视图返回,这样context.view(forKey: .from)的回报nil

没有“从”角度看,我该怎么办?

FlyUpTransition.swift

class FlyUpTransition: NSObject, UIViewControllerAnimatedTransitioning {

    var mode: Mode = .present

    enum Mode {
        case present
        case dismiss
    }

    func transitionDuration(using transitionContext: UIViewControllerContextTransitioning?) -> TimeInterval {
        return TimeInterval(0.45)
    }

    func animateTransition(using transitionContext: UIViewControllerContextTransitioning) {
        switch mode {
        case .present:
            animatePresentation(context: transitionContext)
        case .dismiss:
            animateDismissal(context: transitionContext)
        }
    }

    func animatePresentation(context: UIViewControllerContextTransitioning) {
        guard let fromView = …
Run Code Online (Sandbox Code Playgroud)

uiviewcontroller ios swift ios13

11
推荐指数
2
解决办法
1393
查看次数

UIDocumentPickerViewController iOS13无法正常工作

在我的应用程序上,我曾经UIDocumentPickerViewController允许用户选择文件(导入),但是从iOS 13开始,该功能停止运行,基本上文档选择器处于打开状态,但用户无法选择文件(对文件进行任何操作均不执行任何操作) 。

我制作了一个简单的示例来隔离代码:

class ViewController: UIViewController, UIDocumentPickerDelegate {

    @IBAction func openDocumentPicker(_ sender: Any) {
        let types = [String(kUTTypePDF)]
        let documentPickerViewController = UIDocumentPickerViewController(documentTypes: types, in: .import)
        documentPickerViewController.delegate = self
        present(documentPickerViewController, animated: true, completion: nil)
    }

    func documentPickerWasCancelled(_ controller: UIDocumentPickerViewController) {
        print("Cancelled")
    }

    func documentPicker(_ controller: UIDocumentPickerViewController, didPickDocumentsAt urls: [URL]) {
        print("didPickDocuments at \(urls)")
    }

}
Run Code Online (Sandbox Code Playgroud)

示例项目:https : //github.com/Abreu0101/document-picker-iOS13-issue

参考: 在此处输入图片说明

uidocumentpickerviewcontroller ios13

11
推荐指数
1
解决办法
631
查看次数

UIReferenceLibraryViewController.dictionaryHasDefinition-**返回结果的速度非常慢-iOS 13(模拟器和真实设备)-Xcode 11

刚推出iOS 13时,我正在Xcode 11 GM2中测试我的应用程序,它使用您可以在iPhone上启用的字典进行单词查找。iOS12上的性能已经实现,几乎是瞬时的。

但是,这似乎已随着iOS 13发生了变化。下面的代码是相当标准的,需要3秒钟来响应!!!这在iOS13模拟器和带有iOS13的真实设备上均会发生。

我还没有看到任何有关iOS13 SDK或Xcode 11问题的报道。

这可能是需要报告的错误吗?还是我做错了什么。

这使我的应用看起来无响应。我该如何处理?

这很容易重现,并且与iOS 12.x模拟器相同的代码可以正常工作。

我的代码如下:

import UIKit

//I'm using storyboard with 1 button.

class ViewController: UIViewController {

    @IBOutlet weak var buttonTestUIRefVC: UIButton!

    @IBAction func testUIRefVCTapped(_ sender: UIButton) {

        if UIReferenceLibraryViewController.dictionaryHasDefinition(forTerm: "test") {
            let referenceVC = UIReferenceLibraryViewController(term: "test")
            present(referenceVC, animated: true)
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

从上面的代码,该位 UIReferenceLibraryViewController.dictionaryHasDefinition(forTerm: "test")是引入3秒延迟的原因。

这是调试日志的一部分,我之前没有看过那些“旧状态:1新状态:1”语句,它们仅在iOS 13中显示。这是什么意思?

2019-09-20 09:38:09.175923+0100 DictionaryServicesTest[18527:3511667] Creating client/daemon connection: C94E0479-7F79-4E22-895D-7F1FEFB75C8E
2019-09-20 09:38:09.201599+0100 DictionaryServicesTest[18527:3511667] Got the query meta data reply for: com.apple.MobileAsset.DictionaryServices.dictionary2, response: 0
2019-09-20 09:38:09.218045+0100 …
Run Code Online (Sandbox Code Playgroud)

performance uikit swift ios13

11
推荐指数
1
解决办法
501
查看次数

iOS 13:UITextField rightView的间距问题

我在IOS 13中使用UITextField的正确视图面临间距问题,请参阅以下代码以及ios 13和ios 12.4的屏幕截图

在IOS 12.4模拟器中,在UITextField的右视图(UIButton)中显示适当的空间

在IOS 13.0中,模拟器在UITextField的右视图(UIButton)中存在间距问题

let dropdownButton = UIButton(frame: CGRect(x: 0, y: 0, width: 50, height: txtField.frame.height))
dropdownButton.backgroundColor = UIColor.clear
dropdownButton.setImage(UIImage(named: "ic_DownArrow"), for: UIControl.State())            
txtField.rightView = dropdownButton           
txtField.rightViewMode = .always
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明 在此处输入图片说明

uitextfield ios swift ios13 xcode11

11
推荐指数
2
解决办法
1672
查看次数