简体   繁体   English

Native Tizen - 如何删除图像?

[英]Native Tizen - How to remove image?

Adding new window and popping it works based on Tizen developer docs tutorial .添加新窗口并弹出它的工作原理基于 Tizen 开发人员文档教程 But when I add a image on the second window, after popping it, the image does not vanish.但是当我在第二个窗口上添加图像时,弹出它后,图像并没有消失。

Here's the code on second window with image added:这是添加了图像的第二个窗口上的代码:

static void list_item_doubleclicked_cb(void *data, Evas_Object *obj, void *event_info){
Evas_Object *navi_button;
Evas_Object *nf = data;
Elm_Object_Item *nf_it;


Evas_Object *image = elm_image_add(nf);
evas_object_move(image, 0, 0);
evas_object_resize(image, 400, 300);
evas_object_show(image);

char img_path[128];
char *res_path = app_get_resource_path();
snprintf(img_path, sizeof(img_path), "%s%s%s", res_path, "images/","myImage.png");

elm_image_file_set(image, img_path, NULL);


navi_button = elm_button_add(nf);
elm_object_text_set(navi_button, "Prev");
elm_object_style_set(navi_button, "bottom");
evas_object_smart_callback_add(navi_button, "clicked",
                               prev_btn_clicked_cb, nf);

nf_it = elm_naviframe_item_push(nf, "Second view", NULL,
                                NULL, navi_button, NULL);
}

Here the pop function can clear the button and second window title but it doesn't clear the image.这里的 pop 函数可以清除按钮和第二个窗口标题,但不会清除图像。

All the other code is similar to the linked tutorial.所有其他代码都类似于链接的教程。 The image stays on screen.图像留在屏幕上。 I need to remove it, How can I?我需要删除它,我该怎么做?

Rifat.里法特。

Basically Evas Object dosen't belong to any smart object parents.基本上 Evas 对象不属于任何智能对象父对象。 Its lifetime and basic behaviors works independently, not managed.它的生命周期和基本行为独立工作,不受管理。 Thus you need to control it manually.因此,您需要手动控制它。 However, if you add an image object to a specific smart object parent, the image instance can be managed by its parent.但是,如果将图像对象添加到特定的智能对象父级,则图像实例可由其父级管理。 Meaning, If the parent is deleted, its children are deleted as well.意思是,如果父项被删除,它的子项也会被删除。 Mostly *Container widget works as the smart object parent.大多数情况下 *Container 小部件用作智能对象父级。

You created an image object correctly.But you didn't put it into any containers.您正确创建了一个图像对象。但是您没有将它放入任何容器中。 Naviframe is designed to have a view of the containers such as elm_layout, elm_box, grid, table, etc. You can compose a view using one of them while putting children into the container. Naviframe 被设计为具有容器的视图,例如 elm_layout、elm_box、grid、table 等。您可以在将子项放入容器的同时使用其中之一组成视图。 Thus when naviframe popping is happened, the layout will be removed by naviframe and its children including your image will be removed as well since it's a child of the container.因此,当发生 naviframe 弹出时,布局将被 naviframe 删除,并且它的子项(包括您的图像)也将被删除,因为它是容器的子项。

Otherwise, you should delete image object by explicitly call evas_object_del();否则,您应该通过显式调用 evas_object_del(); 删除图像对象。 when view is popping.当视图弹出时。 Or hide it by call evas_object_hide() when a further view is pushed.或者在推送进一步视图时通过调用 evas_object_hide() 隐藏它。

Hopefully my description is understandable by you.希望我的描述能被你理解。 Thansk.谢谢。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM