0
PeekとPopをUIStackView
の内容で実装しようとしています。問題は、浅いプレス中にオーバーレイ(ぼやけていない部分)に正しい内容が含まれていないことです。それは右の私の指の下にありますので、それは、適切な場所にありますが、その内容は、ビュー内の別の場所から撮影しているように見える:再現するUIStackView PeekとPopオーバーレイのグリッチ
ステップ:
- オープン絵コンテ を使用して、空のiOSプロジェクト
- は
0
に等しいスタックビューのすべての4つの側面から最近傍の制約は、内容を置き換え追加View Controllerのビュー
- に
UIStackView
を追加します次のコードでViewController.swift
:import UIKit class ViewController: UIViewController { @IBOutlet var stackView: UIStackView! override func viewDidLoad() { super.viewDidLoad() registerForPreviewing(with: self, sourceView: stackView) let loremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus sed feugiat ligula. Sed in rutrum lacus, vel auctor felis. Vivamus molestie felis nisi. Mauris euismod eros vitae libero commodo porttitor. Nam posuere, dui vitae aliquam mollis, quam mauris tempus turpis." let label = UILabel() label.numberOfLines = 0 label.text = repeatElement(loremIpsum, count: 4).joined(separator: "\n\n") stackView.addArrangedSubview(label) } } extension ViewController: UIViewControllerPreviewingDelegate { func previewingContext(_ previewingContext: UIViewControllerPreviewing, viewControllerForLocation location: CGPoint) -> UIViewController? { previewingContext.sourceRect = CGRect(x: location.x - 50, y: location.y - 50, width: 100, height: 100) return storyboard?.instantiateInitialViewController() } func previewingContext(_ previewingContext: UIViewControllerPreviewing, commit viewControllerToCommit: UIViewController) { present(viewControllerToCommit, animated: true) } }
はどこでもあなたの(物理)デバイスと力のタッチでアプリを実行しては
私が何か間違ったことをやっている、またはこれは、UIKitのバグですか?
編集:これは、私はそれが動作するように期待される方法である:
registerForPreviewing(with: self, sourceView: view)