如果在一个ViewController中有两个UITableView,另一个有自定义单元格参考,另一个是简单的 [英] what if when two UITableView in one ViewController and one with custom cell refrence and another is a simple

查看:65
本文介绍了如果在一个ViewController中有两个UITableView,另一个有自定义单元格参考,另一个是简单的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在一个ViewController中使用两个UITableView。一个UITableView与自定义单元格的引用,另一个很简单......我写了这段代码,但它给我控制错误可能达到非空函数的结束...

i'm trying to use two UITableView in one ViewController. one UITableView with the reference of custom cell and the other one is simple...I've written this code but it gives me error of control may reach end of non-void function...

所以请给我一个建议...我能做些什么......?

so give me the suggestion for it...what can i do...?

提前感谢...

这里是我的代码......

here, is my code...

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{

    if (tableView==self.categoryTable)
    {
        static NSString *cellIdentifier = @"Cell";
        UITableViewCell *cell1 = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

        if (nil == cell1)
        {
            cell1 = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
        }

        cell1.textLabel.text=[category objectAtIndex:indexPath.row];
        cell1.textLabel.highlightedTextColor = [UIColor redColor];

         return cell1;
    }
    else if (tableView==self.listTable)
    {
        static NSString *simpleTableIdentifier = @"SimpleTableCell";
        RWTListCell *cell2 = (RWTListCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];

        if (cell2 == nil)
        {
            NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
            cell2 = [nib objectAtIndex:0];
        }

        //NSLog(@"%ld",(long)indexxxx);
        //NSLog(@"%lu",(unsigned long)imagesmarry.count );

        cell2.textLabel.text=[[imagesmarry_pictitle objectAtIndex:indexxxx]objectAtIndex:indexPath.row];
        //NSLog(@"%@",[imagesmarry_pictitle objectAtIndex:indexxxx]);

       return cell2;
    }

}


推荐答案

试试这个,你必须初始化单元格为UITableviewViewCell并在之后施放。如果此示例回答您的问题,请告诉我。

try this, you have to init the type the cell as UITableviewViewCell and cast after. Tell me if this sample answer to your question.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 {  
    UITableViewCell *cell;
     if (tableView==self.categoryTable) {

         static NSString *cellIdentifier = @"Cell";
         cell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];

         if (nil == cell) {
            cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:cellIdentifier];
         }

         cell.textLabel.text=[category objectAtIndex:indexPath.row];
         cell.textLabel.highlightedTextColor = [UIColor redColor];



     } else if (tableView==self.listTable) {

         static NSString *simpleTableIdentifier = @"SimpleTableCell";
         cell = (RWTListCell *)[tableView      dequeueReusableCellWithIdentifier:simpleTableIdentifier];

         if (cell == nil) {
              NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"SimpleTableCell" owner:self options:nil];
              cell = (RWTListCell *)[nib objectAtIndex:0];
         }


         //NSLog(@"%ld",(long)indexxxx);
         //NSLog(@"%lu",(unsigned long)imagesmarry.count );

         ((RWTListCell *) cell).textLabel.text=[[imagesmarry_pictitle objectAtIndex:indexxxx]objectAtIndex:indexPath.row];
        //NSLog(@"%@",[imagesmarry_pictitle objectAtIndex:indexxxx]);
}

 return cell;
}

这篇关于如果在一个ViewController中有两个UITableView,另一个有自定义单元格参考,另一个是简单的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆