0

firstViewcontroller で tableview を作成します。そのデータはデータベースから取得されます。データベースから回復しましたが、テーブルビューを関連付けることはできません。cellForRowAtIndexPath にアクセスできません。

これは私がしたことです:

Secondviewcontroller: 
//I insert data in database and I instanciate class where my tableview is and call refresh method

first = [[FirstviewController alloc]initWithNibName:@"FirstviewController" bundle:nil];

[first refreshList];

//in Firstviewcontroller

-(void)refreshList{

   self.tableview= [[[UITableView alloc] initWithFrame:self.view.bounds] autorelease];
    tableview.dataSource = self;
    tableview.delegate = self;

     NSMutableArray *array = [[NSMutableArray alloc] init];
//I recover my data from data base

    IPADAGRIONEActivityList *arrayActivities = [IPADAGRIONEActivity findAll];

    if ([arrayActivities length] > 0)
    {
        for (IPADAGRIONEActivity * oneRec in arrayActivities)
        {
            [array addObject:oneRec];


        }
    }
    //activities is NSMutablearray that contains all my data
    self.activities = array;
 //I build dictionnary 
    [self buildObjectsDictionnary:activities

    NSLog(@"self.act%@",self.tableview);
    [array release];
  [self.tableview reloadData];
}

//numberofrowsinSection: 
          NSLog(@"rows%d",[[objects objectForKey:[objectsIndex objectAtIndex:section]] count]);
            return   [[objects objectForKey:[objectsIndex objectAtIndex:section]] ;


//numberOfSection: 

NSLog(@"nbre of section%d",[objectsIndex count]);
                return [objectsIndex count];}


//CellforRowatInddexPath: It dosen't access to this method

if (cell== nil) {
                cell = [[MHCActivityListCell alloc]init];

            }
            IPADAGRIONEActivity *activite ;

                    cell.activityCategory.text = [NSString stringWithFormat:@"%@", [activite EMAIL]];
                }

            }
4

1 に答える 1

0

self.tableView実際には見えないようです。で再初期化しrefreshDataますが、サブビューとして再度追加しません[self.view addSubview:self.tableView]

前に言ったように、tableView を再初期化するのは正しくなく、悪い使い方ですが、それが問題のようです。

tableview が表示されないため cellForRowAtIndexPath は呼び出されず、セルを表示しようとしません。

于 2013-08-01T18:07:31.997 に答える