Я пытаюсь установить прокрутку на Wkwebview, используемом в мультиплатформе Kotlin, но он никогда не прокручивается. Есть идеи, пожалуйста?scrollView.scrollEnabled = true
scrollView.bounces = true
< /code>
Но это не работает. < /p>
Полный код ниже < /p>
import androidx.compose.foundation.layout.fillMaxSize
import androidx.compose.runtime.Composable
import androidx.compose.runtime.remember
import androidx.compose.ui.Modifier
import androidx.compose.ui.interop.UIKitView
import androidx.compose.ui.viewinterop.UIKitInteropProperties
import androidx.compose.ui.viewinterop.UIKitView
import kotlinx.cinterop.*
import platform.Foundation.NSURL
import platform.WebKit.WKWebView
import platform.WebKit.WKWebViewConfiguration
import platform.CoreGraphics.CGRectMake
@OptIn(ExperimentalForeignApi::class)
@Composable
actual fun WebViewContent(url: String) {
val webViewConfig = remember { WKWebViewConfiguration() }
UIKitView(
factory = {
WKWebView(
frame = CGRectMake(0.0, 0.0, 0.0, 0.0),
configuration = webViewConfig
).apply {
// Load the URL
val nsUrl = NSURL(string = url)
loadRequest(platform.Foundation.NSURLRequest(uRL = nsUrl))
scrollView.scrollEnabled = true
scrollView.bounces = true
}
},
modifier = Modifier.fillMaxSize(),
update = { webView ->
// Update logic when the URL changes
val nsUrl = NSURL(string = url)
(webView as WKWebView).loadRequest(platform.Foundation.NSURLRequest(uRL = nsUrl))
},
properties = UIKitInteropProperties(
isInteractive = true,
isNativeAccessibilityEnabled = true
)
)
}
Подробнее здесь: https://stackoverflow.com/questions/796 ... ot-working
Составьте мультиплатформенный ⇐ IOS
-
- Похожие темы
- Ответы
- Просмотры
- Последнее сообщение