为什么 TTTableViewDragRefreshDelegate 不起作用
我的课程是这样的:
- (id)init
{
NSLog(@"lalallalalala");
if (self = [super init]) {
self.title = @"lalal";
UIImage* image = [UIImage imageNamed:@"tab.png"];
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self.title image:image tag:0] autorelease];
self.variableHeightRows = YES;
id<TTTableViewDataSource> ds = [MainPageDataSource dataSourceWithItems:nil];
ds.model = CreateTabModelWithCurrentSettings();
self.dataSource = ds;
}
return self;
}
- (void)loadView
{
// Create the tableview.
NSLog(@"in MainPageController");
//self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
self.view =[[UIView alloc] init];
self.tableView = [[[UITableView alloc] initWithFrame:TTApplicationFrame() style:UITableViewStylePlain] autorelease];
self.tableView.rowHeight = 80.f;
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.tableView];
}
- (id<UITableViewDelegate>)createDelegate {
return [[[TTTableViewDragRefreshDelegate alloc] initWithController:self] autorelease];
}
CreateDelegate 似乎不起作用,没有拖动&出现刷新。我不知道我的代码有什么问题。
@aporat 视图控制器确实扩展了 TTTableViewController 并且我的代码更改为:
- (id)init
{
NSLog(@"lalallalalala");
if (self = [super init]) {
self.title = @"app";
UIImage* image = [UIImage imageNamed:@"tab.png"];
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self.title image:image tag:0] autorelease];
self.variableHeightRows = YES;
//id<TTTableViewDataSource> ds = [MainPageDataSource dataSourceWithItems:nil];
// ds.model = CreateTabModelWithCurrentSettings();
// self.dataSource = ds;
//self.dataSource = [[[MainPageDataSource alloc] init] autorelease];
}
return self;
}
- (void)createModel {
NSLog(@"in createModel");
self.dataSource = [[[MainPageDataSource alloc] init] autorelease];
}
//- (void)loadView
//{
// // Create the tableview.
//
// NSLog(@"in MainPageController");
//
// self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
// //self.view =[[UIView alloc] init];
// self.tableView = [[[UITableView alloc] initWithFrame:TTApplicationFrame() style:UITableViewStylePlain] autorelease];
// self.toolbarItems = [NSArray arrayWithObjects:
// [TTButton buttonWithStyle:@"toolbarButton:" title:@"Toolbar Button"],
// [TTButton buttonWithStyle:@"toolbarRoundButton:" title:@"Round Button"],
// nil];
//
// self.tableView.rowHeight = 80.f;
// self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// [self.view addSubview:self.tableView];
//
//
//}
//- (void)viewDidLoad {
// [super viewDidLoad];
//
// self.navigationController.navigationBar.alpha = 0;
//}
- (id<UITableViewDelegate>)createDelegate {
return [[[TTTableViewDragRefreshDelegate alloc] initWithController:self] autorelease];
}
仍然没有出现拖动&新鲜的
My class is like:
- (id)init
{
NSLog(@"lalallalalala");
if (self = [super init]) {
self.title = @"lalal";
UIImage* image = [UIImage imageNamed:@"tab.png"];
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self.title image:image tag:0] autorelease];
self.variableHeightRows = YES;
id<TTTableViewDataSource> ds = [MainPageDataSource dataSourceWithItems:nil];
ds.model = CreateTabModelWithCurrentSettings();
self.dataSource = ds;
}
return self;
}
- (void)loadView
{
// Create the tableview.
NSLog(@"in MainPageController");
//self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
self.view =[[UIView alloc] init];
self.tableView = [[[UITableView alloc] initWithFrame:TTApplicationFrame() style:UITableViewStylePlain] autorelease];
self.tableView.rowHeight = 80.f;
self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
[self.view addSubview:self.tableView];
}
- (id<UITableViewDelegate>)createDelegate {
return [[[TTTableViewDragRefreshDelegate alloc] initWithController:self] autorelease];
}
CreateDelegate seems not work, no drag & refresh appears. I don't know what's wrong with my code.
@aporat the view controller does extend TTTableViewController and my code changed to:
- (id)init
{
NSLog(@"lalallalalala");
if (self = [super init]) {
self.title = @"app";
UIImage* image = [UIImage imageNamed:@"tab.png"];
self.tabBarItem = [[[UITabBarItem alloc] initWithTitle:self.title image:image tag:0] autorelease];
self.variableHeightRows = YES;
//id<TTTableViewDataSource> ds = [MainPageDataSource dataSourceWithItems:nil];
// ds.model = CreateTabModelWithCurrentSettings();
// self.dataSource = ds;
//self.dataSource = [[[MainPageDataSource alloc] init] autorelease];
}
return self;
}
- (void)createModel {
NSLog(@"in createModel");
self.dataSource = [[[MainPageDataSource alloc] init] autorelease];
}
//- (void)loadView
//{
// // Create the tableview.
//
// NSLog(@"in MainPageController");
//
// self.view = [[[UIView alloc] initWithFrame:TTApplicationFrame()] autorelease];
// //self.view =[[UIView alloc] init];
// self.tableView = [[[UITableView alloc] initWithFrame:TTApplicationFrame() style:UITableViewStylePlain] autorelease];
// self.toolbarItems = [NSArray arrayWithObjects:
// [TTButton buttonWithStyle:@"toolbarButton:" title:@"Toolbar Button"],
// [TTButton buttonWithStyle:@"toolbarRoundButton:" title:@"Round Button"],
// nil];
//
// self.tableView.rowHeight = 80.f;
// self.tableView.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight;
// [self.view addSubview:self.tableView];
//
//
//}
//- (void)viewDidLoad {
// [super viewDidLoad];
//
// self.navigationController.navigationBar.alpha = 0;
//}
- (id<UITableViewDelegate>)createDelegate {
return [[[TTTableViewDragRefreshDelegate alloc] initWithController:self] autorelease];
}
Still not appears drag & fresh
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的代码存在一些问题:
TTTableViewController
TTTableViewController
会为您加载这些视图。使用标准方法创建数据源。如果您使用
TTTableViewController
,则会自动调用此函数:<前><代码>////////////////////////////////////////////// /////////////////////////////////////////////////////////// /////
- (void)createModel {
self.dataSource = [[[CurrencyDataSource alloc] init] autorelease];
}
如果直接调用此函数会发生什么? (这应该手动显示拖动刷新标题)
There are a few issues with your code:
TTTableViewController
loadView
. TheTTTableViewController
load these views for you.Create your datasource using the standard method. This function is called automatically if you're using
TTTableViewController
:What happens if you call this function directly? (This should manually display the drag to refresh header)