通过 TTURLAction 调用视图控制器中的方法?
我创建了一个下载管理器,它几乎是一个 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您是否尝试过查看示例/TTNavigatorDemo 项目?它有很多 URL 映射示例。
尝试使用
[map from:<#(NSString *)#>对象:<#(id)#>选择器:<#(SEL)#>]
函数,例如:如果我发现自己需要控制器作为对象,我会在应用程序委托中初始化该对象,例如:
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:If I find myself needing the controller as an object, I initialize the object in the app delegate instead, such as:
事实上,它看起来相当简单,尽管我花了一段时间才弄清楚。
Thee20 Navigator 有方法:
通过使用该方法,在整个应用程序中,您可以获得已分配给 url 的视图控制器的实例。然而,诀窍是,如果您
每次获取视图控制器的新实例时都将 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:
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
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.