1

iPad使用してアプリを作成していますが、フォームに編集可能なフィールドをいくつか作成しMonoTouch 2.10.11たいと考えています。MonoTouch.Dialogフィールドの 1 つで を使用しRadioGroupて、ユーザーがオプションのリストから選択できるようにします。のデフォルトの動作はM.T.D、既存のテーブルの上に選択リスト テーブルを表示することです。これはiPhoneレイアウトには最適ですが、このiPadフォームでは、テーブルはフォームの小さな領域にしかなく、ナビゲーション バーはフォームの中央に奇妙に見えます。選択を全画面モーダルとして表示したいのですが、ユーザーは「戻る」ボタンを押して、選択したアイテムで前のフォームに戻ります。

次のような新しいRootElement子孫クラスを作成しました。

public class ModalRootElement : RootElement 
{    
    public override void Selected (DialogViewController dvc, UITableView tableView, NSIndexPath path)
    {
        tableView.DeselectRow (path, false);
        UIViewController uIViewController = this.MakeViewController ();
        this.PrepareDialogViewController (uIViewController);
        dvc.PresentViewController (uIViewController, true, null);
    }

    protected override void PrepareDialogViewController(UIViewController dvc)
    {
        base.PrepareDialogViewController(dvc);

        UIButton button = UIButton.FromType (UIButtonType.RoundedRect);
        button.Frame = new RectangleF (5, 5, 80, 20);
        button.SetTitle ("back", UIControlState.Normal);
        button.TouchUpInside += delegate {
            DialogViewController d = dvc as DialogViewController;

            (d.Root as ModalRootElement).TableView.ReloadData ();

            d.DeactivateController(true);
        };
        dvc.View.AddSubview (button);
    }
}

テーブルは次のコードで実装されます。

var _status = new ModalRootElement("Status", new RadioGroup("status", -1)) {
    (new Section() {
        new RadioElement("New", "status"),
        new RadioElement("In process", "status"),
        new RadioElement("Rejected", "status"),
        new RadioElement("Deferred", "status"),
        new RadioElement("Transferred", "status"),
        new RadioElement("Unknown", "status"),
        new RadioElement("Complete", "status")
    })
};

var _odom = new EntryElement ("Odometer", "current odom", "");
_odom.KeyboardType = UIKeyboardType.DecimalPad;
_odom.TextAlignment = UITextAlignment.Right;

var root = new RootElement ("back") {
    new Section("") {
        _status,
        _odom
    }
};

_dvc = new DialogViewController(root);
_nav = new UINavigationController (_dvc);
_nav.SetNavigationBarHidden (true, false);

アプリを実行するRadioGroupと、ドリルダウンして選択できます。ビューに追加した戻るボタンをクリックすると、モーダル ビューが閉じてRadioSelectedModalRootElementオブジェクトのプロパティが正しく設定されますが、テキストが表示されません。

メソッドをの代わりにSelected()callに変更すると、正しいテキストが表示されますが、テーブルのサイズが正しくありません。の代わりにを使用したときに、 に正しいテキストを表示させる方法はありますか?dvc.ActivateControllerPresentViewControllerModalRootElementRadioGroupRootElementPresentViewControllerActivateController

4

1 に答える 1