I am using a tableView and have implemented its delegates and data source methods as well. I am not new with tableViews and delegates. But still I am getting this crash:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Requesting the window of a view (<UIView: 0xc8b7a00; frame = (0 0; 0 0); transform = [0, 0, 0, 0, 0, 0]; alpha = 0; opaque = NO; autoresize = W; layer = (null)>) with a nil layer. This view probably hasn't received initWithFrame: or initWithCoder:.'
I have used same code for many other tableViews which I am using for this one but I don't know where I am wrong and I also know that this is an old or repeated question but none of the previous solutions worked for me. Here are my delegate and data source methods.
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
return 2;
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
int numberOfRows = 0;
if(section == 0){
numberOfRows = [self.lotteryArray count];
}else{
numberOfRows = 10;
}
return numberOfRows;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
UITableViewCell *cellToReturn = nil;
LedenactiesCell *cell = (LedenactiesCell *)[self.tableView dequeueReusableCellWithIdentifier:@"LedenactiesCell"];
if(!cell){
NSString *nibName = @"LedenactiesCellView";
[self.cellOwner loadMyNibFile:nibName];
cell = (LedenactiesCell *)self.cellOwner.cell;
}
cell.titleLbl = @"My Text for cell";
cellToReturn = cell;
return cellToReturn;
}
I have debugged my code and it never goes to cellForRowAtIndexPath: method.
Any suggestions..
You didn't initialise properly the view containing the table. Use initWithFrame: or initialise it from the Storyboard.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With