我一直試圖實現在UITableView
s的定製一個ScrollView
(鏈接到Page Control
爲清楚起見)中顯示的數據UITTableViewCell
秒的接口。如何實現滾動型內動態UITTableViews與動態量「頁」
我發現了幾個教程,展示瞭如何實現這些功能彼此分開但不是在一起,我真的沒有找到任何關於如何將一些自定義UITableView
加載到控制器中的任何東西。我的基本做法現在歸結到這裏面的UIViewController
的viewDidLoad
:
for (int i = 0; i < 4; i++) {
CGRect frame;
frame.origin.x = self.scrollView.frame.size.width * i;
frame.origin.y = 0;
frame.size = self.scrollView.frame.size;
SceduleTableView *sceduleTable = [[SceduleTableView alloc] initWithFrame:frame];
[sceduleTable setDelegate:sceduleTable];
[sceduleTable setDataSource:sceduleTable];
[self.scrollView addSubview:sceduleTable];
}
我一直在用4頁的測試,但這些將變成一個動態的量,我可以工作了這一點之後。
SceduleTableView從UITableView
繼承,並具有數據源,該數據源獲取帶有對象的數組,該對象不在本地sqlite數據庫中。我已經得到了部分工作,其中所有的SceduleTableViews加載數據爲他們每個人,但此刻的構建失敗並返回此錯誤:
2012-08-13 15:43:18.975 basis[2055:f803] -[SceduleTableView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8bc4800
2012-08-13 15:43:18.976 basis[2055:f803] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SceduleTableView tableView:numberOfRowsInSection:]: unrecognized selector sent to instance 0x8bc4800'
,這個功能並沒有真正做多,但即使永遠達不到的NSLog:
- (NSInteger)numberOfRowsInSection:(NSInteger)section
{
NSLog(@"Should have %d rows", sceduleItems.count);
return sceduleItems.count;
}
而且我知道,無論我嘗試填寫表格與陣列是不是空的,SceduleTableView實例不是零(我看,這可能已經問題)。這些日誌返回此爲每個SceduleTableView
NSLog(@"Array sceduleItems contains %d", sceduleItems.count);
NSLog(@"Trying to reload. Self = %@", self);
[self reloadData];
2012-08-13 15:49:32.183 basis[2259:f803] Array sceduleItems contains 340
2012-08-13 15:49:32.184 basis[2259:f803] Trying to reload. Self = <SceduleTableView: 0xbabb800; baseClass = UITableView; frame = (960 0; 320 440); clipsToBounds = YES; layer = <CALayer: 0x6e29660>; contentOffset: {0, 0}>
我在iOS開發非常新的,說實話,我真的不知道,如果連我的做法是正確的。反饋非常感謝!
謝謝,我的意思是正確覆蓋它。我一定沒有注意。 另外,感謝您指出正確的閱讀材料。我明天就會嘗試。 – GMBrian 2012-08-13 21:33:22