1

私がUIPopoverController使用している があり、クリックするとポップアップが表示される 2 つのボタンがあります。ただし、ポップアップを同時に表示したくありません。つまり、ユーザーが 1 つのボタンを押して、ポップアップが表示されている間に他のボタンを押すことができるようにしたくないということです。ボタンのユーザー操作を無効にする、ポップアップの背後にあるビューを非表示にする、ポップにパススルー ビューを使用するなど、すべてを試したようです。どれもうまくいきません!ユーザー操作の無効化はほとんどの場合機能しているように見えますが、ユーザーがボタンを操作することを禁止しなくなり、アプリケーションがクラッシュします...

popupView.PassthroughViews = new UIView[]{this.View.Superview, this.View, this.Gray}; //gray is another view that sits under the view that calls the popup
this.View.UserInteractionEnabled = false;
this.PositiveMeterBtn.UserInteractionEnabled = false; 
this.View.Hidden = true;

MyUIPopoverControllerはクラス レベルで宣言されており、次のようなコードを実行しました。

if(popupView != null)
    return;

まだ複数のポップアップが表示されます。mono touch/xamarin を使用しています - これは xamarin のバグですか、それとも ios の問題ですか? これを正しい方法で処理していますか?

4

3 に答える 3

2

以前に Xamarin を使用したことはありませんが、ネイティブの Objective-C でうまくいったことは次のとおりです。

[controller setModalInPopover:YES];

controllerポップオーバー内に表示されるView Controllerはどこにありますか。

UIViewController クラス リファレンスから:

@property(nonatomic, readwrite, getter=isModalInPopover) BOOL modalInPopover

このプロパティのデフォルト値は NO です。これを YES に設定すると、所有しているポップオーバー コントローラーは、表示されている間、このビュー コントローラーの外部での対話を禁止します。

于 2013-10-22T03:10:11.953 に答える
1

ポップオーバーをモーダルにすることもできますが、モーダルにするためのコンテンツが含まれていない場合は、ユーザーをブロックしないでください。

通常は、2 つのヘルパー メソッドを作成し、たとえばアプリのデリゲートに配置することをお勧めします。メソッドは、別のポップオーバーが表示される場合、既存のポップオーバーが閉じられるようにします。このようにして、最大のオンUIPopoverControllerになり、解雇を心配する必要がなくなります。

/// <summary>
/// Shows a popover.
/// </summary>
/// <param name='controllerToShow'>the controller to show in the popover</param>
/// <param name='showFromRect'>the rectangle to present the popover from. Not used if showFromItem is specified.</param>
/// <param name='showInView'>the view the popover is hosted in</param>
/// <param name='showFromItem'>the bar button item the popover gets presented from.</param>
/// <param name='popoverContentSize'>the content size of the popover</param>
/// <param name='animated'>If set to <c>true</c>, animated the popover</param>
/// <param name='arrowDirection'>the allowed arrow directions</param>
/// <param name='onDismiss'>callback if the popover gets dismissed. Careful that the object that owns the callback doesn't outlive the popover controller to prevent uncollectable memory.</param>
public static void ShowPopover(UIViewController controllerToShow, RectangleF showFromRect, UIView showInView, UIBarButtonItem showFromItem, SizeF popoverContentSize, bool animated = true, UIPopoverArrowDirection arrowDirection = UIPopoverArrowDirection.Any, EventHandler onDismiss = null)
{
    if(AppDelegateBase.popoverController != null)
    {
        AppDelegateBase.DismissPopover(false);
    }

    if(showFromItem == null && showFromRect.IsEmpty)
    {
        // Nothing to attach the popover to.
        return;
    }

    popoverController = new UIPopoverController(controllerToShow);
    if(!popoverContentSize.IsEmpty)
    {
        popoverController.SetPopoverContentSize(popoverContentSize, false);
    }

    if(onDismiss != null)
    {
        popoverController.DidDismiss += onDismiss;
    }

    // Send a notification that a popover will be presented.
    NSNotificationCenter.DefaultCenter.PostNotificationName("WillPresentPopover", popoverController);

    if(showFromItem != null)
    {
        popoverController.PresentFromBarButtonItem(showFromItem, arrowDirection, animated);
    }
    else 
    {
        popoverController.PresentFromRect(showFromRect, showInView, arrowDirection, animated );
    }
}

/// <summary>
/// Dismisses the popover presented using ShowPopover().
/// </summary>
/// <param name='animated'>If set to <c>true</c>, animates the dismissal</param>
public static void DismissPopover(bool animated = false)
{
    if(popoverController != null)
    {
        popoverController.Dismiss(animated);
    }
    AppDelegateBase.popoverController = null;
}
private static UIPopoverController popoverController;
于 2013-10-22T06:53:21.713 に答える
0

あなたが試すかもしれないことの1つは、メソッドを使用することです

-(BOOL)shouldPerformSegueWithIdentifier:(NSString *)identifier sender:(id)sender

そして、そのメソッドで、ポップオーバー ビュー コントローラーの 1 つが画面上にあるかどうかを確認します。

if (popupView.view.window) {
    return NO;
} else {
    return YES;
}
于 2014-04-03T01:10:20.630 に答える