Xamarin形式:为什么Popupimage显示2次?

时间:2019-01-16 09:18:56

标签: c# xamarin.forms popup

我正在使用jQuery(".mySearch").ajaxlivesearch({ loaded_at: <?php echo time(); ?>, token: <?php echo "'" . $handler->getToken() . "'"; ?>, max_input: <?php echo Config::getConfig('maxInputLength'); ?>, url: <?php echo (APPPATH."/third_party/jQueryLiveSearch/core/AjaxProcessor.php"); ?> onResultClick: function(e, data) { // get the index 1 (second column) value var selectedOne = jQuery(data.selected).find('td').eq('1').text(); // set the input value jQuery('#ls_query').val(selectedOne); // hide the result jQuery("#ls_query").trigger('ajaxlivesearch:hide_result'); }, onResultEnter: function(e, data) { // do whatever you want // jQuery("#ls_query").trigger('ajaxlivesearch:search', {query: 'test'}); }, onAjaxComplete: function(e, data) { } }); (1.1.4.129-beta)显示Rg.Plugins.Popup。我正在使用以下代码显示popupimage

popuppage

我的问题

有时会显示两次弹出窗口。

发布情况

首先,我从一个await PopupNavigation.Instance.PushAsync(new UploadImagePopupPage(imagepath), true); 像下面这样叫popupimage

contentpage

//Checking one condition if (_images.Count != 0) { await PopupNavigation.Instance.PushAsync(new UploadImagePopupPage(picturepath), true); } 中添加了以下代码以显示图像:

UploadImagePopupPage

然后从popupimage.Source = picturepath; 发出单击以下按钮的消息,如下所示。结果,UploadImagePopupPage中的下一张图像将显示为弹出窗口。

observablecollection

然后再次从初始页面调用MessagingCenter.Send<UploadImagePopupPage>(this, "complete"); ,如下所示:

popupimage

我实现了这个目的,以MessagingCenter.Subscribe<UploadImagePopupPage>(this, "complete", (sender) => { ShowImagePopUp(); }); public async void ShowImagePopUp() { try { //Removing current popup await PopupNavigation.Instance.PopAsync(); //Checking one condition if (Utility.picturecount < _images.Count) { // Following popup code invoking 2 times await PopupNavigation.Instance.PushAsync(new UploadImagePopupPage(_images[Utility.picturecount]), true); } else { _images.Clear(); await Navigation.PopModalAsync(); } Utility.loadPhotoAlbum = true; } catch (Exception e) { Debug.WriteLine("Exception:>>"+e); } } 的形式将observablecollection图像一一显示。弹出页面中有一个按钮,单击该按钮时只会出现下一个弹出窗口。有人面对这类问题吗?

1 个答案:

答案 0 :(得分:2)

您需要取消订阅OnDisappearing中的活动

protected override void OnDisappearing() 
{ 
    base.OnDisappearing(); 

    MessagingCenter.Unsubscribe<UploadImagePopupPage>(this, "complete"); 
}