Re: [問題] UITableView動態增加資料
錯了,
insertRowsAtIndexPaths:withRowAnimation:
Inserts rows in the receiver at the locations identified by an array
of index paths, with an option to animate the insertion.
- (void)insertRowsAtIndexPaths:(NSArray *)indexPaths
withRowAnimation:(UITableViewRowAnimation)animation
Parameters
indexPaths
--> An array of NSIndexPath objects each representing a row
--> index and section index that together identify a row in the table view.
這個method是要讓你在指定的indexPath插入資料,
indexPaths這個陣列應該要是 NSIndexPath的陣列,
你的dataArray應該是tableView的dataSource...,
先在source插入資料沒錯,但是下一步要做的是把 NSIndexPath 用 NSArray 封裝起來
int count = [dataArray count];
NSIndexPath indexPath = [NSIndexPath indexPathForRow:count-2 section:0]
NSArray *array = [NSArray arrayWithObject:indexPath];
[tableView insertRowsAtIndexPaths:array withRowAnimation:blablabla];
這樣的code即是在倒數第二個row插入你要的資料~
以上是之前開發的經驗,有說錯還請板上各位糾正~~!
※ 引述《siriuschill (siriuschill)》之銘言:
: 我想自定一個Button
: 點擊下去後
: tableview會自動增加一行
: 上網找了好多資料
: 都是在navigation上點擊實現
: 有嘗試過寫到Button裡
: 還是不行
: [self.tableView reloadData]
: 還是不能刷新
: 請問各位大大
: 我是不是漏了什麼動作呢?
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 111.248.95.215
→
05/23 01:02, , 1F
05/23 01:02, 1F
推
05/23 01:27, , 2F
05/23 01:27, 2F
→
05/23 11:56, , 3F
05/23 11:56, 3F
→
05/23 12:51, , 4F
05/23 12:51, 4F
推
05/23 12:55, , 5F
05/23 12:55, 5F
→
05/23 15:59, , 6F
05/23 15:59, 6F
→
05/23 19:55, , 7F
05/23 19:55, 7F

→
05/23 20:03, , 8F
05/23 20:03, 8F
→
05/23 20:04, , 9F
05/23 20:04, 9F
→
05/23 20:04, , 10F
05/23 20:04, 10F
→
05/23 20:05, , 11F
05/23 20:05, 11F
推
05/23 22:15, , 12F
05/23 22:15, 12F
→
05/31 08:47, , 13F
05/31 08:47, 13F
討論串 (同標題文章)
本文引述了以下文章的的內容:
完整討論串 (本文為第 2 之 3 篇):
MacDev 近期熱門文章
PTT數位生活區 即時熱門文章