English 中文(简体)
可用电文重载数据/复读(可能存在的重复问题)
原标题:UITableView reloading data / refreshing (possible duplication issue)

在我正在复读的“i”申请中,我有UITableView。 http://www.un.org/Depts/DGACM/index_chinese.htm 表格对其中一个单元的文字价值进行了更新。

然而,以下法典似乎产生了不想要的副作用。 看来,每当UITableView复读时,就会发现UISegmentedControl(以及可能的图像——我并不肯定)相对于现有的图像。

我注意到的唯一原因是,每重新造就一个几乎让人接受的边界,就开始在被调查的联邦调查局周围形成,而且申请速度明显放缓。 我非常感谢对我目前的困境提出的任何建议/编码解决办法。

// Customize the appearance of table view cells.
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    static NSString *CellIdentifier = @"Cell";


    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
    if (cell == nil) {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
    }

    NSUInteger section = indexPath.section;
    NSUInteger row = indexPath.row;

    // Set up the cell...       


    //populates the personal info section
    if (section == kPersonalInfoAddSection) {

        if (row == kNameRow) {

                    //Other code irrelevant to this question was removed for the sake of clarity
        }
        else if(row == kHeightRow) {

            cell.imageView.image = [UIImage imageNamed:@"tableview_height_label.png"];
                    //THIS IS THE TEXT I M TRYING TO UPDATE
            cell.textLabel.text = [Formatter formatHeightValue:mainUser.heightInMM forZone:self.heightZone];
            cell.detailTextLabel.text = REQUIRED_STRING;

        }
    }

    //populates the units section
    if (section == kUnitsSection) {

        if (row == kHeightUnitsRow) {
            NSArray *heightUnitsSegments = [[NSArray alloc] initWithObjects:FT_AND_IN_STRING, M_AND_CM_STRING, nil];

            UISegmentedControl *heightUnitControl = [[UISegmentedControl alloc] initWithItems:heightUnitsSegments];

            CGRect segmentRect = CGRectMake(90, 7, 200, 30);
            [heightUnitControl setFrame:segmentRect];
            //[heightUnitControl setSelectedSegmentIndex:0];
            [heightUnitControl addTarget:self action:@selector(heightSegmentClicked:) forControlEvents:UIControlEventValueChanged];
            heightUnitControl.tag = kHeightSegmentedControlTag;

            cell.textLabel.text = @"Height:";
            cell.detailTextLabel.text = @"(units)";
            [cell.contentView addSubview:heightUnitControl];

            [heightUnitsSegments release];
            [heightUnitControl release];

        }
        else if(row == kWeightUnitsRow) {

                    //Other code irrelevant to this question was removed for the sake of clarity    

        }
    }

    return cell;
}

事先感谢你!

最佳回答

你们是正确的,它正在创立一个新案例,即UISegmentedControl。 这是因为你使用了通用的手机识别器,@“Cell”,然后每次增加UISegmentedControl,永远不会去除。 这些囚室配有UISegmentedControl,你取回了该牢房,并再次增加了控制。

你们可以使用更具体的手机识别器,如果是手机! 不详 已有控制。 或者每当你不使用已经控制过的卡路里,就建造一个新的牢房。

根据图像观点,你只是把细胞形象视为财产,而没有给囚室增添新的观点,这样一来就能够更换。

由于你试图更新案文,与被调查者联盟没有关系。 管制 我认为,你应当能够使用更具体的手机识别器,并且只增加在电池制造方面的控制。

问题回答
- (void)viewDidLoad {
    [super viewDidLoad];
    NSArray *arr1=[NSArray arrayWithObjects:@"img1.jpg",@"img2.jpg",nil];
    NSArray *arr2=[NSArray arrayWithObjects:@"img1.jpg",@"img2.jpg",@"img3.jpg",@"img4.jpg",@"img5.jpg",@"img6.jpg",nil];
    NSArray *arr3=[NSArray arrayWithObjects:@"img6.jpg",@"img5.jpg",@"img2.jpg",@"img1.jpg",nil];

    Imgs = [[NSArray alloc] initWithArray:[NSArray arrayWithObjects:arr1,arr2,arr3,nil]];


    NSDictionary *dic1=[NSDictionary dictionaryWithObjectsAndKeys:@"Ahmedabad",@"Name",@"Picture 5.png",@"Rating",@"Picture 1.png",@"Photo",arr1,@"img",nil];
    NSDictionary *dic2=[NSDictionary dictionaryWithObjectsAndKeys:@"Rajkot",@"Name",@"Picture 5.png",@"Rating",@"Picture 2.png",@"Photo",nil];
    NSDictionary *dic3=[NSDictionary dictionaryWithObjectsAndKeys:@"Baroda",@"Name",@"Picture 5.png",@"Rating",@"Picture 7.png",@"Photo",nil];

    tblArray=[[NSArray alloc] initWithObjects:dic1,dic2,dic3,nil];
    [myTbl reloadData];

}

- (void)viewWillAppear:(BOOL)animated {
    [super viewWillAppear:animated];
    self.navigationController.navigationBarHidden=NO;
    [self.navigationController.navigationBar setUserInteractionEnabled:YES];

}

- (void)viewWillDisappear:(BOOL)animated {
    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden=YES;
}



-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return [tblArray count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    NSString *CellIdentifer=[NSString stringWithFormat:@"%i",indexPath.row];
    UITableViewCell *cell=[tableView dequeueReusableCellWithIdentifier:CellIdentifer];
    if(cell==nil){
        cell=[self myCustomCell:CellIdentifer dicToSet:[tblArray objectAtIndex:indexPath.row]];
        [cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
    }
    return cell;
}

-(UITableViewCell*)myCustomCell:(NSString*)CellIdentifer dicToSet:(NSDictionary*)dicToSet{
    UITableViewCell *cell=[[[UITableViewCell alloc] initWithFrame:CGRectMake(0, 0, 320, 44) reuseIdentifier:CellIdentifer] autorelease];

    UIImageView *imgV=[[UIImageView alloc] initWithFrame:CGRectMake(2, 2, 40, 40)];
    [imgV setImage:[UIImage imageNamed:[dicToSet valueForKey:@"Photo"]]];
    [cell addSubview:imgV];
    [imgV release];

    UILabel *lbl=[[UILabel alloc] initWithFrame:CGRectMake(44, 2, 276, 20)];
    [lbl setText:[dicToSet valueForKey:@"Name"]];
    [cell addSubview:lbl];
    [lbl setBackgroundColor:[UIColor clearColor]];
    [lbl setFont:[UIFont fontWithName:@"Helvetica-Bold" size:18]];
    [lbl release];


    UIImageView *imgV1=[[UIImageView alloc] initWithFrame:CGRectMake(44, 24, 70, 20)];
    [imgV1 setImage:[UIImage imageNamed:[dicToSet valueForKey:@"Rating"]]];
    [cell addSubview:imgV1];
    [imgV1 release];


    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{

    nxtPlcDtl=[[plcFullDtl alloc] initWithNibName:@"plcFullDtl" bundle:nil];
    nxtPlcDtl.dict=[[NSDictionary alloc] initWithDictionary:[tblArray objectAtIndex:indexPath.row]];
    nxtPlcDtl.Imgs = [Imgs objectAtIndex:indexPath.row];
    nxtPlcDtl.comment1 = [comment1 objectAtIndex:indexPath.row];
    nxtPlcDtl.vedio = [vedio objectAtIndex:indexPath.row];

    [self.navigationController pushViewController:nxtPlcDtl animated:YES];



    }




相关问题
Code sign Error

I have created a new iPhone application.I have two mach machines. I have created the certificate for running application in iPhone in one mac. Can I use the other mac for running the application in ...

ABPersonViewController Usage for displaying contact

Created a View based Project and added a contact to the AddressBook using ABAddressBookRef,ABRecordRef now i wanted to display the added contact ABPersonViewController is the method but how to use in ...

将音频Clips从Peter改为服务器

我不禁要问,那里是否有任何实例表明从Peit向服务器发送音响。 I m不关心电话或SIP风格的解决办法,只是一个简单的袖珍流程......

• 如何将搜查线重新定位?

我正试图把图像放在搜索条左边。 但是,问题始于这里,搜索条线不能重新布署。

热门标签