作者zonble (zonble)
看板MacDev
标题Re: [问题] 如何等待alert结束?
时间Sat Sep 4 03:56:47 2010
※ 引述《markzog21 (残羽星辰)》之铭言:
: - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
: return [sectionArray count];
: }
UITableView 要求至少要有一个 section,你这边最好改写,
因为 array count 可能是 0。一旦回传 0 就会出现 exception。
: - (UITableViewCell *)tableView:(UITableView *)tableView
: cellForRowAtIndexPath:(NSIndexPath *)indexPath
: {
: NSInteger row = [indexPath row];
: NSInteger section = [indexPath section];
: // Create a cell if one is not already available
: UITableViewCell *cell = [self.tableView
: dequeueReusableCellWithIdentifier:@"any-cell"];
: if (cell == nil)
: cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero
: reuseIdentifier:@"any-cell"] autorelease];
: // Set up the cell by coloring its text
: [cell.textLabel setText: [sectionArray objectAtIndex:0]];
呃,照你前面产生 NSMutableArray 的方式,[sectionArray objectAtIndex:0]
应该会回传 NSArray,但是你现在却把 NSArray 当做 NSString 用。
: return cell;
: }
--
zonble.net
cocoa.zonble.net
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 114.44.188.242
1F:→ markzog21:用好了,谢谢@@"原来tableview还有这层关系在 09/06 18:53
2F:→ markzog21:可是如果我改第一个回传sectionArray成 09/06 18:54
3F:→ markzog21:if([sectionArray count] == 0) return 1; 09/06 18:54
4F:→ markzog21:else return [sectionArray count]; 09/06 18:54
5F:→ markzog21:在进入画面时反而会当掉...我这样改也有问题?? 09/06 18:55
6F:→ markzog21:反而没改就对了 只是所有的cell的title 都有小刮号() 09/06 18:55
7F:→ markzog21:让我百思不得其解 我改cell.textLabel 的地方是改成 09/06 18:56
8F:→ markzog21:[cell.textLabel setText: [NSString stringWithFormat: 09/06 18:56
9F:→ markzog21:@"%@",[sectionArray objectAtIndex:0]]]; 09/06 18:56
10F:推 markzog21:我懂了== 我刚刚引入的是array 不是cell 改好了ˊˋ 09/06 19:59