我在我的應用程序中創建一個收件箱模塊。我想問一下,我想在Json的數據插入之後在UITableView中創建一個標籤程序。通過我們點擊並獲取更多數據?如何做到這一點?像在臉書的例子,我們點擊消息,並向下移動,我們點擊加載更多的消息?在加載更多的消息標籤我發送另一個電話加載更多的消息。從json加載數據後在表視圖上創建標籤
1
A
回答
1
好吧,你必須一起破解這一切。這是通常的做法得到「加載更多的數據」在你的UITableViewcell
方法所需
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return dataRows+1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
//after setting tableviewcell
if(indexPath.row==dataRows){
[email protected]"Load More Rows";
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row==dataRows){
//there you can write code to get next rows
}
}
確定這就是黑客將不得不開始。看看這個CODE。
,這似乎是最重要的方法是
- (void)reloadTableView:(int)startingRow
0
爲此,您可以將其設置爲按鈕。如果在tableview中單擊該按鈕,則可以獲得更多數據,或者可以像十乘十數據一樣逐步獲取數據。
創建自定義單元格,並設置自定義的鈕釦電池也給名btnLoadMore
在頭文件
@interface myViewController : UIViewController {
int loadMoreTableInt;
int paginationInt;
}
在.m文件
- (void)viewDidLoad {
[super viewDidLoad];
loadMoreTableInt = 0;
paginationInt = 1;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
customCell *cell=(customCell*)[tableView dequeueReusableCellWithIdentifier:@"Reuse"];
NSArray *nib=[[NSBundle mainBundle] loadNibNamed:@"customCell" owner:self options:nil];
if(cell == nil) {
cell=[nib objectAtIndex:0];
}
if(loadMoreTableInt-1> indexPath.row) {
cell.labelName.text = [NSString stringWithFormat:@"%@",[modelRoot.arrayName objectAtIndex:indexPath.row]];
} else {
if(cell == nil) {
cell=[nib objectAtIndex:1];
}
[cell.btnLoadMore setTitle:[NSString stringWithFormat:@"Load More "] forState:UIControlStateNormal];
cell.btnLoadMore.tag=indexPath.row;
cell.accessoryType=UITableViewCellAccessoryNone;
[cell.btnSeeMorebtnLoadMore addTarget:self action:@selector(loadmoreButtonAction:) forControlEvents:UIControlEventTouchUpInside];
cell.selectionStyle=UITableViewCellSelectionStyleNone;
}
在loadmoreButtonAction給出任何類似的代碼這
-(void)loadmoreButtonAction:(id)sender {
@try {
UIButton *btn=(id)sender;
paginationInt=paginationInt+1;
[tableview reloadData];
CGPoint point;
point.x=40;
point.y=btn.tag*53;
NSIndexPath *path = [tableview indexPathForRowAtPoint:point];
[tableview scrollToRowAtIndexPath:path atScrollPosition:UITableViewScrollPositionTop animated:NO];
}@catch (NSException *exception) {
}
}
+0
泰克斯我會檢查nd讓你知道:) – 2014-10-30 06:35:12
相關問題
- 1. 從SQLite加載數據到列表視圖還是從數組創建列表視圖更高效?
- 2. 從其他視圖回來後從表視圖重新加載數據
- 3. Codeigniter在新標籤中加載視圖
- 4. UIWeb視圖負載數據之前視圖被加載標籤欄
- 5. 創建具有一個視圖上加入多個標籤
- 6. 在h2數據庫上創建視圖
- 7. 根據標籤長度從xib創建的大小視圖
- 8. 從數據庫中加載數據以在java中創建融合圖表?
- 9. 創建數據庫表標籤
- 10. 通過從數據庫加載數據創建Gridview列標題
- 11. 在iphone應用程序加載視圖後加載數據
- 12. excel宏創建數據透視表與列標籤
- 13. 滾動到底部後在表格視圖中加載數據
- 14. 爲圖表數據創建JSON
- 15. 從JSON數據創建html表格
- 16. 從JSON數據創建聯繫表
- 17. 在以前加載的視圖上更新標籤?
- 18. 從表視圖到標籤的數組數據
- 19. 使用標籤欄項加載視圖!
- 20. 標籤欄視圖不會加載
- 21. 獲取視圖標籤創建程序
- 22. Laravel 5從刀片視圖中創建json數據的分頁
- 23. 在pdf上創建標籤
- 24. Xcode上的白色視圖 - 它不加載標籤和圖像
- 25. 加載數據後創建主鍵和標識列
- 26. 在附加數據庫中創建成員表,SPROC,視圖
- 27. 從sencha加載json數據
- 28. AngularJS加載JSON數據,然後從它解析/加載HTML
- 29. 從另一個視圖返回後再次加載表視圖
- 30. 哪個dispatch_async方法建議將json數據加載到表視圖控制器?
你指的是一個tableview中的無限滾動? – avismara 2014-10-29 11:09:46
是的..我從我的服務器獲得25條記錄..我想創建一個標籤獲得25條記錄後,加載更多的記錄。 – 2014-10-29 11:13:46
maam只是從Web Service獲取數據,並重新計算numberofrowinindexpath中的計數,它將根據您擁有的記錄數來加載。 – sanjeet 2014-10-29 11:22:09