对viewcontroller的开始/结束外观转换的不平衡调用

时间:2013-12-11 22:55:59

标签: ios objective-c ios6 storyboard

尝试使用

检索单元格时,此错误立即开始显示
static NSString *CellIdentifier1 = @"Cell1";
        UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];

而不是

static NSString *CellIdentifier1 = @"Cell1";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }

我在另一个表视图控制器中使用了相同的方法,并且完全正常。我不确定重用标识符是否在这里产生差异。

我在右侧的属性窗格中将重用标识符作为Cell1。

以下是我正在使用的方法:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier1 = @"Cell1";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier1];

NSString* str = [NSString stringWithFormat:@"%@.jpg",[farmLand soilType].lowercaseString];

    UIImageView *soilImageView = (UIImageView *)[cell viewWithTag:4];
    soilImageView.image = [UIImage imageNamed:str];

    UILabel *soilNameLabel = (UILabel *)[cell viewWithTag:5];
    soilNameLabel.text = [farmLand soilType];

    UILabel *areaNameLabel = (UILabel *)[cell viewWithTag:6];
    areaNameLabel.text = [NSString stringWithFormat:@"%d",farmLand.area];
 return cell;
}


- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{


    UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    CropTableViewController *storeDetalVC = [mystoryboard instantiateViewControllerWithIdentifier:@"cropTable"];


    FarmLand *farmLand1 = [filteredItemist objectAtIndex:[indexPath row]];
    storeDetalVC.soilName=[farmLand1 soilType];


    [self.searchBar resignFirstResponder];
    [self.navigationController pushViewController:storeDetalVC animated:YES];
}

如果方法更改如下,我的代码可以正常工作:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *CellIdentifier = @"Cell";
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

    if (cell == nil) {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] ;
        cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    }


    UIImage *background = [self cellBackgroundForRowAtIndexPath:indexPath];

    UIImageView *cellBackgroundView = [[UIImageView alloc] initWithImage:background];
    cellBackgroundView.image = background;
    cell.backgroundView = cellBackgroundView;

    // Configure the cell...
    FarmLand *farmLand = [filteredItemist objectAtIndex:[indexPath row]];
    //cell.item
    cell.textLabel.text = [farmLand soilType];


    cell.detailTextLabel.text = [NSString stringWithFormat:@"%d",farmLand.area];
       return cell;
}

但是我想设计我的自定义布局并填写我在故事板中的viewcontroller上定义的相应字段。

请帮帮我。

编辑:

它是固定的。问题是我使用initwithidentifier从segue和代码调用下一个视图。

0 个答案:

没有答案