在UITableViewCell Tap上更改视图控制器

时间:2014-06-23 18:57:46

标签: c# ios uitableview xamarin

当有人点击表视图单元格时,我正在尝试更改视图控制器。但是,我不按传统方式做。我正在执行实际检测到tap的方法,因此我可以从任何其他类中使用它。我是这样做的:

TableSource.cs

public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
        {
            if (OnRowSelected != null) {
                OnRowSelected (this, new RowSelectedEventArgs (tableView, indexPath));
            }
        }

public class RowSelectedEventArgs : EventArgs
        {
            public UITableView tableView { get; set; }
            public NSIndexPath indexPath { get; set; }

public RowSelectedEventArgs(UITableView tableView, NSIndexPath indexPath) : base()
            { 
                this.tableView = tableView;
                this.indexPath = indexPath;
            }
        }

public event EventHandler<RowSelectedEventArgs> OnRowSelected;

Request.cs

tableSourceTable.OnRowSelected += (object sender, TableSource<Datum>.RowSelectedEventArgs e) => {

 vc = new InstagramModalController (){instaData = tableSourceTable.instaData[e.indexPath.Row]};
                         this.navControl.PushViewController(this.vc,true);

                        this.getMediaID(tableSourceTable.instaData[e.indexPath.Row].link);

                        new UIAlertView(tableSourceTable.instaData[e.indexPath.Row].user.full_name.ToString(), 
                            tableSourceTable.instaData[e.indexPath.Row].caption.text.ToString(), null, "OK", null).Show();
                        e.tableView.DeselectRow (e.indexPath, true);
                    };

这就是TableSource类中的所有代码,如果有任何更改,我都可以。

0 个答案:

没有答案
相关问题