我無法把頭轉過來。當頁面加載時,一切工作正常 - 我可以向上和向下鑽取,但是當我在tableview上下拉時,'stream'(在下面突出顯示的位置)變得不等於任何東西。但錯誤只是有時候。通常它返回鍵/對。當我在桌子上上下移動時,Iphone xcode模擬器崩潰
如果知道一個可以理解上面怎麼給你一個的NSMutableDictionary對象
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *FirstLevelCell = @"FirstLevelCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:FirstLevelCell];
if(cell == nil)
{
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:FirstLevelCell] autorelease];
}
NSInteger row = [indexPath row];
//NSDictionary *stream = (NSDictionary *) [dataList objectAtIndex:row];
NSString *level = self.atLevel;
if([level isEqualToString:@"level2"])
{
NSMutableDictionary *stream = [[NSMutableArray alloc] init];
stream = (NSMutableDictionary *) [dataList objectAtIndex:row];
//流值是測試//(INT)[$ VAR計數]}鍵/值對 (INT) [$ VAR計數]}鍵/值對
if ([stream valueForKey:@"title"])
{
cell.textLabel.text = [stream valueForKey:@"title"];
cell.textLabel.numberOfLines = 2;
cell.textLabel.font =[UIFont systemFontOfSize:10];
NSString *detailText = [stream valueForKey:@"created"];
cell.detailTextLabel.numberOfLines = 2;
cell.detailTextLabel.font= [UIFont systemFontOfSize:9];
cell.detailTextLabel.text = detailText;
NSString *str = @"http://www.mywebsite.co.uk/images/stories/Cimex.jpg";
NSData *imageURL = [[NSData alloc] initWithContentsOfURL:[NSURL URLWithString:str]];
UIImage *newsImage = [[UIImage alloc] initWithData:imageURL];
cell.imageView.image = newsImage;
[stream release];
}
}
else
{
cell.textLabel.text = [dataList objectAtIndex:row];
}
return cell;
}
感謝您的時間
你爲什麼要給你的字典對象分配一個可變數組然後重新賦值?你正在泄漏內存......可能不是你的問題,但仍然是一個問題 – Daniel 2010-04-16 15:16:14