Re: [問題] 如何等待alert結束?

看板MacDev作者 (zonble)時間15年前 (2010/09/04 03:56), 編輯推噓1(109)
留言10則, 1人參與, 最新討論串8/8 (看更多)
※ 引述《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

09/06 18:53, , 1F
用好了,謝謝@@"原來tableview還有這層關係在
09/06 18:53, 1F

09/06 18:54, , 2F
可是如果我改第一個回傳sectionArray成
09/06 18:54, 2F

09/06 18:54, , 3F
if([sectionArray count] == 0) return 1;
09/06 18:54, 3F

09/06 18:54, , 4F
else return [sectionArray count];
09/06 18:54, 4F

09/06 18:55, , 5F
在進入畫面時反而會當掉...我這樣改也有問題??
09/06 18:55, 5F

09/06 18:55, , 6F
反而沒改就對了 只是所有的cell的title 都有小刮號()
09/06 18:55, 6F

09/06 18:56, , 7F
讓我百思不得其解 我改cell.textLabel 的地方是改成
09/06 18:56, 7F

09/06 18:56, , 8F
[cell.textLabel setText: [NSString stringWithFormat:
09/06 18:56, 8F

09/06 18:56, , 9F
@"%@",[sectionArray objectAtIndex:0]]];
09/06 18:56, 9F

09/06 19:59, , 10F
我懂了== 我剛剛引入的是array 不是cell 改好了ˊˋ
09/06 19:59, 10F
文章代碼(AID): #1CWLC3J6 (MacDev)
討論串 (同標題文章)
文章代碼(AID): #1CWLC3J6 (MacDev)