Я сделал небольшой проект, который замораживает после следующих шагов: < /p>
- Запустите приложение < /li>
Повернуть голосование < /li>
. Громкий < /li>
Выключите голосование < /li>
Прокручивать и вниз по прокрутке вверх и вниз < /li>
< /ul>
Использование профилялора времени, элементы в основной нити, сопровождаемые значительными каплями: < /p>
if X 85.1% 0 Scloe #2 in #2 #2 #2 #2 #2 #2 #2. ViewRenderHost.Render (Интервал: updatedIsplaylist: targetTimeStamp
- 13.05 S 58,1% 4.00 MS viewgraph.updateOutputs (async

/> - 5,76 S 25,6% 19,00 MS MayoutoutScrollableTransform.updateValue () < /li>
< li>1,73 S 7,7% 2,00 мс специализирован nativedictionary.setValue (< /em>: forkey: isunique:) < /li>
флаг. 0x100a8c908
< li>311,00 мс 1,4% 165,00 мс __thread_stack_pcs
- Changing LazyVStack for VStack
- Removing the VStack from the Section
- Removing the header: parameter from the Section
- Reducing the range of the Foreach
- Переместите текст (vorbatim: "нижний текст") за пределами lazyvstack
struct ContentView: View {
var body: some View {
VStack {
VStack(alignment: .leading) {
Image(systemName: "pencil.circle.fill")
Text("Title")
Text("Label")
}
ScrollView {
LazyVStack {
Section {
VStack {
ForEach(0..
appdelegate: < /p>
@main
class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow?
func application(
_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?
) -> Bool {
let window = UIWindow(frame: UIScreen.main.bounds)
window.rootViewController = UINavigationController(rootViewController: MainViewController())
window.makeKeyAndVisible()
self.window = window
return true
}
}
< /code>
mainviewcontroller: < /p>
import UIKit
import SwiftUI
final class MainViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let swiftUIView = ContentView()
let hostingController = UIHostingController(rootView: swiftUIView)
addChild(hostingController)
hostingController.view.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(hostingController.view)
NSLayoutConstraint.activate([
hostingController.view.topAnchor.constraint(equalTo: view.topAnchor),
hostingController.view.bottomAnchor.constraint(equalTo: view.bottomAnchor),
hostingController.view.leadingAnchor.constraint(equalTo: view.leadingAnchor),
hostingController.view.trailingAnchor.constraint(equalTo: view.trailingAnchor)
])
hostingController.didMove(toParent: self)
view.backgroundColor = .white
}
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... iftui-view
Мобильная версия