Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/ruby/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 如何在tableView中存储数据&;下次更新它_Iphone - Fatal编程技术网

Iphone 如何在tableView中存储数据&;下次更新它

Iphone 如何在tableView中存储数据&;下次更新它,iphone,Iphone,这是存储球员的姓名和分数,但每次只显示表中的一条记录 它必须显示列表中最后的前十名分数 主要问题是,这并不是存储和显示每个分数数据 请指导我解决这个问题 提前感谢。您不能使用表视图存储数据。表视图是一个UI元素,可用于显示数据。 对于存储数据,您可以使用: 不能使用表视图存储数据。表视图是一个UI元素,可用于显示数据。 对于存储数据,您可以使用: 您需要给出要在UITableView中显示的每个控件的标记,并且在单元格==nil条件之外,您需要使用特定标记检索该控件,然后为其指定文本

这是存储球员的姓名和分数,但每次只显示表中的一条记录

它必须显示列表中最后的前十名分数

主要问题是,这并不是存储和显示每个分数数据

请指导我解决这个问题


提前感谢。

您不能使用表视图存储数据。表视图是一个UI元素,可用于显示数据。 对于存储数据,您可以使用:


  • 不能使用表视图存储数据。表视图是一个UI元素,可用于显示数据。 对于存储数据,您可以使用:


  • 您需要给出要在
    UITableView
    中显示的每个控件的标记,并且在
    单元格==nil
    条件之外,您需要使用特定标记检索该控件,然后为其指定文本。

    您需要给出要在其中显示的每个控件的标记
    UITableView
    并且在
    单元格==nil
    条件之外,您需要使用特定的标记检索该控件,然后为其指定文本。

    是..但我想添加一些内容,以便您更好地理解。。。当加载tableview时,cell==nil只被调用一次,因此您可以在cell==nil中设置标签文本,这样第一次设置的文本将保持不变,因此您必须在cell==nil之外设置文本..是..但是我想添加一些内容,以便您更好地理解。。。当加载tableview时,cell==nil仅被调用一次,因此您可以在cell==nil中设置标签文本,这样第一次设置的文本将保持不变,因此您必须在cell==nil外部设置文本。。
    -(IBAction)btnSaveScore:(id)sender
    {
       if(!dictWinData)
          dictWinData = [[NSMutableDictionary alloc] init];
    
    
        array = [NSMutableArray arrayWithObjects:txt_EnterName.text,
                                                 [NSString stringWithFormat:@"%i",iTap], nil];
    
        int increment = 0;
    
        NSLog(@"array data is:--> %@",array);
    
        for (int intWinData = 1; intWinData < [array count]; intWinData++)
        {
            [dictWinData setObject:array forKey:[NSString stringWithFormat:@"NameScore%d",increment]];
            increment++;
        }
    }
    
    - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
    {
        return [dictWinData count];
    }
    
    - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
    {
        static NSString *CellIdentifier = @"Cell";
    
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
        if (cell == nil)
        {
            cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
    
            ArrStr = [dictWinData valueForKey:[NSString stringWithFormat:@"NameScore%d",indexPath.row]];
            UILabel *lblDayName = [[UILabel alloc] initWithFrame:CGRectMake(10, 50, 160, 21)];
            lblDayName.text = [ArrStr objectAtIndex:0];
            lblDayName.textColor = [UIColor blackColor];
            lblDayName.font = [UIFont boldSystemFontOfSize:17.0];
            lblDayName.backgroundColor = [UIColor clearColor];
            [cell.contentView addSubview:lblDayName];
            [lblDayName release];
    
            UILabel *lblLow = [[UILabel alloc] initWithFrame:CGRectMake(180, 50, 40, 21)];
            lblLow.text = [ArrStr objectAtIndex:1];
            lblLow.textColor = [UIColor blackColor];
            lblLow.font = [UIFont boldSystemFontOfSize:17.0];
            lblLow.backgroundColor = [UIColor clearColor];
            [cell.contentView addSubview:lblLow];
            [lblLow release];
        }
    return cell;
    }