更新对话框视图控制器中的BackButton文本

时间:2013-06-18 09:20:36

标签: xamarin.ios xamarin monotouch.dialog

我有一个monotouch对话框视图控制器。我有许多嵌套的根元素

        public RootElement LoginSection()
    {
        //var rootSection = new Section("");
        var root = new RootElement ("I'm already a member");

        EntryElement emailEnt = new EntryElement ("Login","Username or Email","");
        EntryElement passwdEnt = new EntryElement ("Password","Password","",true);

        StyledStringElement loginBtn = new StyledStringElement ("Login"){
            Accessory = UITableViewCellAccessory.DetailDisclosureButton
        };
        Section loginDetails = new Section("Your Details"){emailEnt,passwdEnt,loginBtn};
        loginBtn.Tapped += () => {
            var result = ApiOperations.ApiValidateLoginCredentials (emailEnt.Value, passwdEnt.Value);
            if (result) {
                var login = DataOperations.DbGetLogin ();
                //first time user so we need to save their details into the db
                if (login == null) {

                } else {
                    BTProgressHUD.Show ("Logging In", -1, BTProgressHUD.MaskType.Black);
                    BTProgressHUD.InvokeInBackground (delegate {
                        ApiOperations.QrCode (login.ConsumerId);
                        ApiOperations.ApiConsumer (login.ConsumerId);
                        AuthenicatedActionCompleted.Invoke (this, new EventArgs ());
                        BTProgressHUD.Dismiss ();
                    });
                }
            } else {
                //didnt work
                using (var alert = new UIAlertView ("Unable to login", "Please try again.", null, "OK", null))
                    alert.Show ();
            }
        };
        root.Add (loginDetails);
        return root;
        }

我的问题是每个元素标题的长度。我的顶级根标题也很长,例如欢迎来到我的申请

如果我点击后面按钮上方的一个rootelement显示“欢迎来....”理想情况下我希望按钮显示“后退”与长串。

可以更新吗?

1 个答案:

答案 0 :(得分:1)

好的解决了。如果其他人有同样的问题,这对我有用。

最后一行是诀窍。

public override void LoadView ()
    {
        base.LoadView ();
        View.BackgroundColor =UIColor.Clear;
        TableView.BackgroundView = null;
        var background = UIImage.FromBundle(Resources.BackgroundImagePath);
        ParentViewController.View.BackgroundColor = UIColor.FromPatternImage (background);
        this.NavigationItem.BackBarButtonItem = new UIBarButtonItem ("Back", UIBarButtonItemStyle.Plain, null);
    }