gpt4 book ai didi

c# - 如何访问 UITableViewSource 下的 NavigationController.PushViewController?

转载 作者:行者123 更新时间:2023-11-29 03:03:50 24 4
gpt4 key购买 nike

如何访问 UITableviewSource 类中的 NavigationController

在行选择时,我想导航到另一个 UIController

这是我的代码,

public class RootTableSource : UITableViewSource
{
IList<VendorDetails> tableItems;
string cellIdentifier = "UIViewController";

ReportsList reportList;
AddNewReport addnewReport;

public RootTableSource()
{
}

public RootTableSource (IEnumerable<VendorDetails> items)
{
tableItems = items.ToList ();
}

public override void RowSelected (UITableView tableView, NSIndexPath indexPath)
{
tableView.DeselectRow (indexPath, true);

// Redirect to another UIController....
}

public VendorDetails GetItem (int id)
{
return tableItems [id];
}
}

最佳答案

你有在 AppDelegate 中实例化 UINavigationController 吗?

像这样...

@property (strong, nonatomic) UINavigationController *navigationViewController;

那么你应该可以从 AppDelegate 委托(delegate)访问 UINavigationController

#import "AppDelegate.h"

@implementation yourClassName

-(void)functionName{

AppDelegate *appdelegate = (AppDelegate*)[[UIApplication sharedApplication]delegate];

appdelegate.navigationViewController; //your UINavigationController

[appdelegate.navigationViewController pushViewController:yourUIViewController animated:YES];

}

@end

希望得到帮助~

编辑:

抱歉,我以前从未使用过 Xamarin

所以我认为这是一种糟糕的实现方式...

但看起来可行

AppDelegates.cs

[Register ("AppDelegate")]
public partial class AppDelegate : UIApplicationDelegate
{

UIWindow window;
HomeScreen home;
public static UINavigationController navigation;
//set navigation public and static

public override bool FinishedLaunching (UIApplication app, NSDictionary options)
{
window = new UIWindow (UIScreen.MainScreen.Bounds);
home = new HomeScreen ();
navigation = new UINavigationController(home);
window.RootViewController = navigation;
window.MakeKeyAndVisible ();
return true;
}
}

yourClassName.cs

AppDelegate.navigation
//access navigation

希望再次得到帮助...

关于c# - 如何访问 UITableViewSource 下的 NavigationController.PushViewController?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23002029/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com