没有崩溃消息我的表查看崩溃

时间:2015-09-08 10:00:08

标签: objective-c uitableview

我的代码请验证朋友:

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    NSInteger count=[[arrParsingProduct valueForKey:@"description"] count];
    return count;
}

-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSInteger count=[[arrParsingProduct valueForKey:@"description"]count];

    return count;

}

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


    productSub=[tableView dequeueReusableCellWithIdentifier:@"cell1"];

    NSLog(@"entering");
    productSub.lblSubProduct.text=[NSString stringWithFormat:@"%@",[[arrParsingProduct objectAtIndex:indexPath.row] valueForKey:@"description"]];


    return productSub;

}

-(UIView*)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
    NSString *str=[NSString stringWithFormat:LocalImage@"%@",[[arrParsingProduct objectAtIndex:section] valueForKey:@"image"]];
    self.imgHeader.image=[UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:str]]];
    self.lblHeaderproduct.text=[NSString stringWithFormat:@"%@",[[arrParsingProduct objectAtIndex:section] valueForKey:@"name"]];
    self.lblHeaderCost.text=[NSString stringWithFormat:@"%@",[[arrParsingProduct objectAtIndex:section]valueForKey:@"price"]];
    [self.btnHeader addTarget:self action:@selector(touchup:) forControlEvents:UIControlEventTouchUpInside];
    return self.view;
}

没有崩溃讯息。我试图用断点找出问题。我很困惑。请问任何人告诉我可能是什么问题?

1 个答案:

答案 0 :(得分:0)

在viewForHeaderInSection中,您将返回self.view;这不正确的方式创建UIView对象并返回该对象。

UIStoryboard *objStoryboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
    ViewController *objVC = [objStoryboard instantiateViewControllerWithIdentifier:@"headerView_identifier"];
return objVC.view;