From 3d0a8282e2c144560475611420029902e2fbb828 Mon Sep 17 00:00:00 2001 From: Caisking <3449750381@qq.com> Date: Thu, 3 Oct 2024 20:38:18 +0800 Subject: [PATCH] =?utf8?q?=E4=BF=AE=E5=A4=8D=E8=AE=AD=E7=BB=83=E8=AE=BE?= =?utf8?q?=E7=BD=AESlice=E5=86=85=E5=AD=98=E6=B3=84=E6=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- .../nativeui/traing/include/TraingNomalView.h | 1 - .../nativeui/traing/src/TraingNomalView.cpp | 16 +++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h index 3930b10b3..581ea6102 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/include/TraingNomalView.h @@ -64,7 +64,6 @@ namespace OHOS TraingNomalView(TraingNomalView &&) = delete; TraingNomalView &operator=(TraingNomalView &&) = delete; - UIViewGroup *container_ = nullptr; UILabelExt *sporttitle_ = nullptr; UIButton *buttonGo_ = nullptr; UILabelButtonExt *buttonSet_ = nullptr; diff --git a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp index 47e881a78..8f4bc3a0f 100644 --- a/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp +++ b/code/sdk/application/wearable/fd230app/nativeui/traing/src/TraingNomalView.cpp @@ -72,7 +72,10 @@ namespace OHOS /* DeInit:删除组件*/ void TraingNomalView::DeInit() { - container_->RemoveAll(); + if(container_ != nullptr) + { + container_->RemoveAll(); + } if (sporttitle_ != nullptr) { delete sporttitle_; @@ -129,7 +132,7 @@ namespace OHOS container_->SetDraggable(true); PreLoad(); - RootView::GetInstance()->Add(container_); + SetContainerView(container_); SetKeyActListener(); } @@ -156,10 +159,13 @@ namespace OHOS void TraingNomalView::OnStop() { View::OnStop(); + if (container_ != nullptr) + { + container_->RemoveAll(); + delete container_; + container_ = nullptr; + } RootView::GetInstance()->RemoveAll(); - - RootView::GetInstance()->ClearOnKeyActListener(); - // FocusManager::GetInstance()->ClearFocus(); return; } } -- 2.17.1