小编fl0*_*034的帖子

使用UISearchController时,iOS 13 UIBarButtonItem不可单击且UINavigationBars重叠

我有一个导航栏,其中包含一些UIBarButtonItem按钮和类似的UISearchBar挂钩

var searchController: UISearchController!

override func viewDidLoad() {
    super.viewDidLoad()

    title = "Test"

    tableView.delegate = self
    tableView.dataSource = self

    searchController = UISearchController(searchResultsController: nil)
    navigationItem.searchController = searchController

    // This leads to the bug
    searchController.hidesNavigationBarDuringPresentation = false

    navigationItem.leftBarButtonItem = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(leftTapped))
    navigationItem.rightBarButtonItem = UIBarButtonItem(barButtonSystemItem: .action, target: self, action: #selector(rightTapped))
}
Run Code Online (Sandbox Code Playgroud)

场景:我点击搜索栏,然后点击取消。

  • 问题1:除非我触摸屏幕的最外面的像素,否则条形按钮对触摸没有反应(仅在模拟器和鼠标单击时才可能)。

  • 问题2:当我按下另一个视图控制器时,导航项重叠。

在此处输入图片说明

当我使用hidesNavigationBarDuringPresentation = true它时,它的工作就像预期的那样。


该问题出现在使用Xcode 11.0和11.1的带槽口和非带槽口的iPhone iOS 13.0和13.1上。

这是整个测试项目:https : //github.com/fl034/HidesNavigationBarDuringPresentationTest


我已经提起雷达(您也应该提起诉讼),但是也许你们中的有些人已经找到了解决方法?


更新1:iOS …

uinavigationcontroller ios uisearchcontroller ios13

36
推荐指数
2
解决办法
1504
查看次数

iOS:目前的视图控制器programmaticicallyly

我正在使用该presentViewController:animated:completion:方法转到另一个视图控制器.

这是我的代码:

AddTaskViewController *add = [[AddTaskViewController alloc] init];
[self presentViewController:add animated:YES completion:nil];
Run Code Online (Sandbox Code Playgroud)

此代码转到另一个,UIViewController但另一个控制器为空.我一直在使用故事板,但现在我需要在代码中完成.

objective-c uiviewcontroller ios uistoryboard presentviewcontroller

34
推荐指数
2
解决办法
12万
查看次数

使用Swift的Encodable将可选属性编码为null,无需自定义编码

我想JSONEncoder使用struct符合Encodable协议的Swift编码可选字段.

默认设置是JSONEncoder使用encodeIfPresent方法,这意味着nil从Json中排除的值.

如何在不编写自定义encode(to encoder: Encoder)函数的情况下为单个属性覆盖此属性,我必须在其中实现所有属性的编码(如本文在"自定义编码"下建议的那样)?

例:

struct MyStruct: Encodable {
    let id: Int
    let date: Date?
}

let myStruct = MyStruct(id: 10, date: nil)
let jsonData = try JSONEncoder().encode(myStruct)
print(String(data: jsonData, encoding: .utf8)!) // {"id":10}
Run Code Online (Sandbox Code Playgroud)

encoding json ios swift codable

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

在iOS 11上滑动时AVPlayerViewController黑屏

我正在AVPlayerViewControlleriPad-App上播放视频文件(H.264,AAC,MP4-Container).一切都在iOS 10中运行.而且在iOS 11中它正确播放视频.

但是在iOS 11中,当我开始向任何方向滑动时,它会立即使视频变黑并使音频静音.它还显示底部时间轴旁边的加载指示器.

它也忽略了allowsPictureInPicturePlayback属性,因此它不会在iOS 11上显示PIP-Button.

这是我使用的代码:

avPlayerController = AVPlayerViewController()
avPlayerController?.showsPlaybackControls = true
avPlayerController?.allowsPictureInPicturePlayback = true
avPlayerController?.player = AVPlayer(url: videoUrl as URL)
avPlayerController?.player?.play()            

self.present(self.avPlayerController!, animated: true, completion: nil)            

avPlayerController?.player?.actionAtItemEnd = AVPlayerActionAtItemEnd.none
NotificationCenter.default.addObserver(self, selector: #selector(onVideoCompleted), name: NSNotification.Name.AVPlayerItemDidPlayToEndTime, object: self.avPlayerController!.player?.currentItem)
Run Code Online (Sandbox Code Playgroud)

此功能可在视频结束时关闭视频播放器:

func onVideoCompleted(notification:Notification) {
    self.avPlayerController?.player = nil
    self.avPlayerController?.dismiss(animated: true, completion: nil)
}
Run Code Online (Sandbox Code Playgroud)

当屏幕黑屏时,我在控制台中看到了这个:

AVOutputDeviceDiscoverySession (FigRouteDiscoverer) 
>>>> -[AVFigRouteDiscovererOutputDeviceDiscoverySessionImpl 
outputDeviceDiscoverySessionDidChangeDiscoveryMode:]: Setting device discovery 
mode to DiscoveryMode_Presence (client: MyAppName)
Run Code Online (Sandbox Code Playgroud)

video swift avplayerviewcontroller ios11

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

为什么SFAuthenticationSession同意警报显示Xcode项目名称而不是App名称?

我正在使用SFAuthenticationSession身份验证通过OAuth2.

用户必须同意的同意将以下消息显示为警报:

"[Xcode-Project-Name]"想要使用"[Server-URL]"登录.这允许应用和网站共享有关您的信息.

为什么不提及应用程序显示名称?

它是App Store提交后的App名称吗?

ios ios11 sfauthenticationsession

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

如何知道用户何时在 PDFKit 的 PDFView 中滑动到下一页?

在我的 iOS 应用程序中,我使用的是PDFViewwith pdfView.usePageViewController(true, withViewOptions: nil).

我想隐藏PDFThumbnailView用户滑动到另一个页面的时间。

我已经看过里面了,PDFViewDelegate但没有合适的功能可以使用。

pdfkit pdfview ios swift

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

PDFView不会突出显示搜索结果

我正在尝试PDFView,并希望突出显示搜索到的单词。我在这里关注这个小教程(请参阅搜索段落)。

我正在为我的PDF找到匹配项,但是当我设置时pdfView.highlightedSelections = searchedItems什么也没发生。

这是我的代码(VC扩展了PDFDocumentDelegate)

var document: PDFDocument!
var searchedItems: [PDFSelection] = []


override func viewDidLoad() {
    super.viewDidLoad()

    let url = Bundle.main.url(forResource: "test3", withExtension: "pdf")
    document = PDFDocument(url: url!)
    pdfView.document = document
    pdfView.document?.delegate = self
}

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
    pdfView.document?.findString("Product", withOptions: .caseInsensitive)
}

func documentDidEndDocumentFind(_ notification: Notification) {
    pdfView.highlightedSelections = nil
    pdfView.highlightedSelections = searchedItems
}

func documentDidFindMatch(_ notification: Notification) {
    if let selection = notification.userInfo?.first?.value as? PDFSelection {
        selection.color = …
Run Code Online (Sandbox Code Playgroud)

pdfkit pdfview ios swift

0
推荐指数
2
解决办法
1382
查看次数