通过 TTURLAction 调用视图控制器中的方法?

发布于 2024-12-10 01:20:58 字数 376 浏览 0 评论 0原文

我创建了一个下载管理器,它几乎是一个 TTTableViewController,它附带的 DataModel 几乎是一个 ASINetworkQueue。

因此,当我在视图控制器中创建一个函数,依次调用我的 [dataModel addDownloadWithNameAndUrl: url:] 时,我会在 NetworkQueue 中添加一个新的下载,该下载启动并显示在 TTTableViewController 上并更新进度条和其余的。

我还将 DownloadManagerViewController 类映射到 URL,并且可以使用 TTNavigator 打开下载管理器。

现在我的问题。有没有办法可以调用 url 来执行请求的功能,而无需切换到视图控制器?我怎样才能完成一些

I've created a Download Manager which is pretty much a TTTableViewController and it's accompanying DataModel is a pretty much an ASINetworkQueue.

So, when I've created a function in my view controller that in turns call my [dataModel addDownloadWithNameAndUrl: url:] and I get a new download added to the NetworkQueue, which starts, and is being displayed on the TTTableViewController and updates progress bars and the rest.

I've also mapped the DownloadManagerViewController class to a URL, and I can use the TTNavigator to open the download manager.

Now for my question. Is there a way I can call the url to execute the requested function without switching to the View Controller? How could I accomplish some

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

似狗非友 2024-12-17 01:20:58

您是否尝试过查看示例/TTNavigatorDemo 项目?它有很多 URL 映射示例。

尝试使用 [map from:<#(NSString *)#>对象:<#(id)#>选择器:<#(SEL)#>]函数,例如:

[map from:@"tt://order/send" toObject:_controller selector:@selector(sendOrder)];

如果我发现自己需要控制器作为对象,我会在应用程序委托中初始化该对象,例如:

 _playerController = [[PlayerController alloc] init];
 [map from:@"radio://player/(initWithStation:)" toViewController:_playerController transition:UIViewAnimationTransitionNone];

Have you tried looking in the samples/TTNavigatorDemo project? It has a lot of URL mapping examples.

Try using the [map from:<#(NSString *)#> toObject:<#(id)#> selector:<#(SEL)#>] function, such as:

[map from:@"tt://order/send" toObject:_controller selector:@selector(sendOrder)];

If I find myself needing the controller as an object, I initialize the object in the app delegate instead, such as:

 _playerController = [[PlayerController alloc] init];
 [map from:@"radio://player/(initWithStation:)" toViewController:_playerController transition:UIViewAnimationTransitionNone];
夜还是长夜 2024-12-17 01:20:58

事实上,它看起来相当简单,尽管我花了一段时间才弄清楚。

Thee20 Navigator 有方法:

- (id) viewControllerForURL: (NSString *) url;

通过使用该方法,在整个应用程序中,您可以获得已分配给 url 的视图控制器的实例。然而,诀窍是,如果您

[map @"url" toViewController: <class>];

每次获取视图控制器的新实例时都将 url 设置为 a 。

然而,就我而言,我想使用已经实例化的视图控制器,因此我需要将 url 设置为 sharedViewController

因此,我在视图控制器中添加了一个新方法,现在我可以调用该方法,而无需将 UI 切换到它。

Well as a matter of fact it appears to be rather simple although it took me a while to figure it out.

Thee20 Navigator has method:

- (id) viewControllerForURL: (NSString *) url;

By using that, throughout the application you can get an instance of your view controller that you have assigned to the url. However the trick is that if you have set the url as a

[map @"url" toViewController: <class>];

each time you get a new instance of the View Controller.

In my case however, I wanted to use the already instantiated view controller so I need to setup the url as a sharedViewController.

So I've added a new method to my view controller which now I can call without switching the UI to it.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文