【问题标题】:three20 - loading external Data for TTViewControllerthree20 - 为 TTViewController 加载外部数据
【发布时间】:2010-02-27 16:26:48
【问题描述】:

我创建了一个 TTViewController,它应该显示来自外部(网络)源的一些信息。 我已经使用了一些使用 TTModel 系统的 TTableViewControllers(我为我的 TTTableViewControllers 创建了一个 TTURLRequestModel 和一个 TTListDataSource)

使用 TTViewController 的方法是什么? 是否还有类似 DataSource 和 Request Model 的东西,或者我是否必须为我的 ViewController 分配 TTURLRequestDelegate 并运行一个简单的 URL 请求?

我问是因为我不知道用来自网络的数据填充我的视图控制器的“最佳”和“最新”方式是什么。我知道如何对 tableviews 执行此操作,但对视图却不知道。

提前致谢

编辑:一些代码

我的 singlePostViewController:

@interface singlePostViewController : TTModelViewController 
       singlePostModel *_singlepostmodel; 
@end 
- (void) createModel { 
        _singlepostmodel = [[singlePostModel alloc] init]; 
} 

还有我的 singlePostModel

@interface singlePostModel : TTURLRequestModel { 
} 

@end 

但是现在该怎么办?在哪里加载我的东西并进行设置?

【问题讨论】:

    标签: iphone objective-c cocoa-touch three20


    【解决方案1】:

    查看TTModelViewController 课程。你会想要继承它。您在 createModel: 方法中创建 TTURLRequestModel 并将“self”添加到模型的委托列表中。有很多有趣的方法可以满足您的要求。

    特别是,this PDF 显示了模型、数据源和控制器类之间的良好关系。

    【讨论】:

    • hm 你有类似的例子,或者教程吗?
    • 添加了指向有用 PDF 的链接。
    【解决方案2】:

    查看此推特示例 https://github.com/facebook/three20/tree/master/samples/TTTwitter 它的简单示例。

    您需要在 TTURLRequestModel 的子类中覆盖“-(void) load:(TTURLRequestCachePolicy)cachePolicy more:(BOOL)more”方法来获取远程数据。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-18
      • 1970-01-01
      相关资源
      最近更新 更多