iphone - 当我们从表中重新加载数据时,UITable View 数据源和委托(delegate)的顺序是什么?

标签 iphone ios objective-c

你好我是 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]; 当我们重新加载表时,我的 Controller 进入表数据源...... - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 在这个 Controller 低于这个线之后 [table_AdviseTestDetails reloadData]; 在这个 Controller 进入之后...... - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 我在那里有问题......我想当我们重新加载表然后首先运行 UITableview 的所有数据源和委托(delegate)然后运行其他东西...... 所以在我上面的代码中....我想用这个重新加载表数据

    [table_AdviseTestDetails reloadData];

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

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

Controller 在 [table_AdviseTestDetails reloadData] 之后出现; 这条线......怎么能做到这一点..请解决这个问题......提前致谢

最佳答案

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

#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

关于iphone - 当我们从表中重新加载数据时,UITable View 数据源和委托(delegate)的顺序是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19290065/

相关文章:

iphone - 新的 iOS 7 状态栏在 Xcode 5 中编译的应用程序中保留了 20px 的范围

jquery - Bootstrap 崩溃一半在 iPhone 上工作

ios - 在通知中使用Pushwoosh发送数据

objective-c - 在 iOS 框架内播放视频(并将其居中)

ios - UICollectionView 和滚动程序错误

objective-c - GPS 航向 iOS

iphone - 无法在 bundle 中加载 NIB

iphone - 如何制作 "infinite"UIPickerView?

iphone - 如何使用 Xcode 4 在 xib 中设置对象标签?

ios - 为什么已删除的文件在新写入文件后又会回来? swift 2.0