没有根的野草,漂浮的命途

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

cellForRowAtIndexPath 方法不能正常加载的问题

首先借鉴了前辈们的结论:

tableView的另一个方法结果返回不正确:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
 
但是我查了一下,我的这个numberOfRowsInSection方法能正常加载,但是此时打印出的存放section的数组arrayOfSection的count为0.
后来发现是arrayOfSections没有初始化的原因,java转c真不习惯啊

-(id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

{

    self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if(self!=nil)

    {

        arrayOfSections=[[NSMutableArray alloc] init];//问题所在

        for (int i=1; i<=3; i++) {

            [self.arrayOfSectionsaddObject:[selfnewSectionWithIndex:i withCellCount:i+2]];

        }

        

    }

   

    returnself;

}

posted on 2012-03-15 14:23  针尖上的舞者  阅读(275)  评论(0)    收藏  举报