3

您好,我是 iOS 的初学者在我的一项活动中,我想重新加载表数据......然后我应用了这段代码......

 -(void)buttonpress
{

   for(int i=0;i<buttonarr.count;i++)
   {
       NSString *butt=[NSString stringWithFormat:@"%@",[buttonarr objectAtIndex:i]];

       for(int j=0;j<LabelTag.count;j++)
       {
            NSString *labelbutt=[NSString stringWithFormat:@"%@",[LabelTag objectAtIndex:j]];

            if([butt isEqualToString:labelbutt])
            {
                  NSIndexPath *indexPath1 =[NSIndexPath indexPathForRow:j inSection:0];
                        NSLog(@"indexPath %@",indexPath1);
                        UITableViewCell *mycel=[self->table_AdviseTestDetails cellForRowAtIndexPath:indexPath1];
                        NSLog(@"cell %@",mycel);

                        UILabel *mybutton=(UILabel*)[mycel viewWithTag:100+j];
                        // mybutton.selected=YES;
                        NSLog(@"label %@",mybutton.text);


                        r=r+[mybutton.text floatValue];
                        NSLog(@"r %f",r);


                    }

                }
            }

          range=1;

[table_AdviseTestDetails reloadData];

        netcharges.text=0;
            z1=0;

            NSLog(@"label arr %@",LabelArr);


                   for(int i=0;i<LabelArr.count;i++)
                    {
                        NSString *y= [NSString stringWithFormat:@"%@",[[LabelArr objectAtIndex:i] valueForKey:@"value"]];


                     z1=z1+[y integerValue];


                        netcharges.text=[NSString stringWithFormat:@"%.2f",z1];
                        NSLog(@"net %@",netcharges.text);
                        //balance.text=[NSString stringWithFormat:@"%.2f",z];

                    }
                    netcharges.text=[NSString stringWithFormat:@"%.2f",[netcharges.text floatValue]-r];

                    NSLog(@"net %@",netcharges.text);
                    point.text=[NSString stringWithFormat:@"%.f",(floor([netcharges.text integerValue]/[[[Point_Result objectAtIndex:0]valueForKey:@"Value"] integerValue]))*[[[Point_Result objectAtIndex:0]valueForKey:@"Points"] integerValue]];
                    balance.text=netcharges.text;
                    NSLog(@"net %@",balance.text);


        }

这是我的代码请忽略所有认为存在的代码 [table_AdviseTestDetails reloadData]; 当我们重新加载表时,我的控制器进入表数据源... - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 并且在这个控制器之后这个 [table_AdviseTestDetails reloadData]; 在这个控制器进入之后...... - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 我有问题.....我想当我们重新加载表时首先所有数据源和委托UITableview 运行然后运行其他的东西.....所以在我上面的代码中......我想要拳头重新加载表数据使用这个

    [table_AdviseTestDetails reloadData];

然后运行表的所有委托和数据源.....

   - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
     - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 

控制器位于 [table_AdviseTestDetails reloadData] 的下方;这条线.....怎么能这样做..请解决这个问题......提前谢谢

4

1 回答 1

10

这些是一般顺序,我不包括所有方法,只是需要的方法都在这里

#pragma mark
#pragma mark - Table view data source
1) -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
2) -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
3) -(float)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
4) -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

#pragma mark
#pragma mark - Table view delegate
1) -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
于 2013-10-10T07:57:36.490 回答