내 앱에 기본 뒤로 버튼을 구현하려고합니다.BB10 QML 파일에서 뒤로 버튼이 작동하지 않습니다.
페이지에서 웹보기를 사용하고 있습니다.
포럼에서 찾은 버튼과 코드가 추가되었습니다.
Button {
id: button1
text: "Back"
onClicked: {
WebView.goBack();
}
나는 뭔가가 부족합니까?
내 앱에 기본 뒤로 버튼을 구현하려고합니다.BB10 QML 파일에서 뒤로 버튼이 작동하지 않습니다.
페이지에서 웹보기를 사용하고 있습니다.
포럼에서 찾은 버튼과 코드가 추가되었습니다.
Button {
id: button1
text: "Back"
onClicked: {
WebView.goBack();
}
나는 뭔가가 부족합니까?
이 간단한 코드입니다
main.qml
import bb.cascades 1.0
NavigationPane {
id: nav
Page {
id: pg
titleBar: TitleBar {
id: tb
title: "Mini Web Browser"
}
Container {layout:StackLayout {
orientation:LayoutOrientation.TopToBottom
}
Container {
layout:StackLayout {
orientation:LayoutOrientation.LeftToRight
}
TextField {
id:tf
hintText: "Enter you Url"
inputMode: TextFieldInputMode.Url
input.submitKey: SubmitKey.Go
layoutProperties: StackLayoutProperties {
spaceQuota: 5
}
}
Button {
id:go
imageSource: "asset:///ic_done.png"
layoutProperties: StackLayoutProperties {
spaceQuota: 1
}
onClicked: {
console.log(tf.text);
console.log(myWebView.urlChanged(tf.text))
}
}
}
ScrollView {
scrollViewProperties.pinchToZoomEnabled: true
scrollViewProperties.scrollMode: ScrollMode.Both
WebView {
id:myWebView
url: "https://www.google.com/search?q="+tf.text
settings.devicePixelRatio: 1.0
onLoadingChanged: {
if (loadRequest.status == WebLoadStatus.Started) {
statusLabel.setText("Loading start..................")
tb.title=myWebView.title
statusLabel.visible=true
}
else if (loadRequest.status == WebLoadStatus.Succeeded) {
statusLabel.setText("Loading finished.")
statusLabel.visible=false
tb.title=myWebView.title
}
else if (loadRequest.status == WebLoadStatus.Failed) {
statusLabel.setText("Load failed.")
}
}
}
}
ProgressIndicator {
id: pi
verticalAlignment: VerticalAlignment.Fill
fromValue:0
toValue: 100
value:myWebView.loadProgress
onValueChanged: {
if(value<100)
pi.visible=true
else if(value== 100)
pi.visible=false
}
}
Label{
id: statusLabel
verticalAlignment: VerticalAlignment.Bottom
horizontalAlignment: HorizontalAlignment.Fill
text: "ram"
//visible:
textStyle.textAlign: TextAlign.Left
textStyle.color: Color.Black
}
}
actions:[
ActionItem {
enabled: myWebView.canGoBack
title: "Back"
ActionBar.placement: ActionBarPlacement.OnBar
imageSource: "asset:///ic_previous.png"
onTriggered: {
myWebView.goBack()
}
},
ActionItem {
title: "Forword"
enabled: myWebView.canGoForward
ActionBar.placement: ActionBarPlacement.OnBar
imageSource: "asset:///ic_next.png"
onTriggered: { myWebView.goForward();
}
},
ActionItem {
title:myWebView.loading ? "Stop" : "Reload"
ActionBar.placement: ActionBarPlacement.OnBar
imageSource:myWebView.loading ? "asset:///ic_cancel.png" : "asset:///ic_rotate.png"
onTriggered: {myWebView.loading ? myWebView.stop():myWebView.reload();
}
}
]
}
}
이 내가 추가에 대한 응용 프로그램 웹 사이트에 대한 링크를 포함 할 수 있습니다 자산 디렉토리에서 HTML로로드되는 도움말 페이지에 사용하는 것입니다 정보. 피터의 의견이 해결책이 될 수 있습니다. 이 경우 뒤로 버튼은 TitleBar에 배치되지만 작업 표시 줄, 오버 플로우 메뉴 또는 다른 위치에 쉽게 배치 될 수 있습니다.
import bb.cascades 1.0
Page {
titleBar: TitleBar {
title: "Help"
scrollBehavior: TitleBarScrollBehavior.NonSticky
dismissAction: ActionItem {
title: "Close"
onTriggered: {
helpSheet.close();
}
imageSource: "asset:///images/ic_cancel.png"
}
acceptAction: ActionItem {
title: "Back"
enabled: webView.canGoBack
onTriggered: {
webView.goBack();
}
}
}
id: helpPage
objectName: "helpSheet"
ScrollView {
Container {
layout: StackLayout {
}
WebView {
id: webView
url: "local:///assets/help.html"
layoutProperties: StackLayoutProperties {
}
topMargin: 21.0
}
}
}
}
이 버튼은 'WebView'ID를 가진 객체를 어떻게 찾을 수 있습니까? 이 프로그램을 실행하면 장치 로그에 'WebView를 찾을 수 없음'과 같은 내용이 표시됩니까? –