Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Iphone 在TableView上显示项目-新手_Iphone_Objective C_Xcode - Fatal编程技术网

Iphone 在TableView上显示项目-新手

Iphone 在TableView上显示项目-新手,iphone,objective-c,xcode,Iphone,Objective C,Xcode,我有一个桌面视图 在每个单元格中,我显示以下字符A,B,C等 当用户单击a时,我需要该页面转到另一个视图,该视图显示另一个tableView,该tableView打印以下文本America, 澳大利亚。(本部分已完成) 当用户单击B时,视图将转到另一个页面,但由于没有使用字符B声明的国家,因此它显示一个 空桌子 当用户单击CcountriesCanada和China时,将显示 我想做的是,当用户单击B时,由于没有任何国家,我不希望页面被重新定向到- 另一个显示空表的页面 我应该如何解决这个问题

我有一个桌面视图

在每个单元格中,我显示以下字符
A
B
C

当用户单击
a
时,我需要该页面转到另一个视图,该视图显示另一个tableView,该tableView打印以下文本
America
澳大利亚
。(本部分已完成)

当用户单击
B
时,视图将转到另一个页面,但由于没有使用字符
B
声明的国家,因此它显示一个 空桌子

当用户单击
C
countries
Canada
China
时,将显示

我想做的是,当用户单击
B
时,由于没有任何国家,我不希望页面被重新定向到- 另一个显示空表的页面

我应该如何解决这个问题

***所有国家/地区名称都是从sqlite加载的

我添加了如下代码,这就是为什么我的所有屏幕都指向另一个视图(并且
B
显示一个空的tableView)


在Countries类中创建一个方法,以允许父视图控制器检索记录计数。如果计数为0,则不要推送视图

另外,我认为CountriesViewController之类的东西比Countries更容易混淆

 - (void)viewDidLoad

    Array=[[NSMutableArray alloc]init];
    [Array1 addObject:@"A",@"B",@"C",nil];

 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 Static NSString *cellIdentifier=@"cell";
    cell=[tbView dequeueReusableCellWithIdentifier:cellIdentifier];
    if(cell==nil)
    {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

     if(tableView==self.tbView)
    {
         cell.textLabel.text=[Array objectAtIndex:indexPath.row];
    } 
    cell.textLabel.font=[UIFont boldSystemFontOfSize:14];
    return cell;
}
 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 if(tableView==self.tbView)
    { 
        return [Array count];
    }
//when select the tableview cell want you want set codes here
 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    {
}
-(void)tableView:(UITableView*)tableView未选择RowatineXpath:(NSIndexPath*)indexPath

//代码在这里
}

Illep,你的问题解决了吗?没有。如果您有解决方案,请在用户单击B时告诉我
,因为没有任何国家/地区,我不希望页面被重新定向到另一个显示空表的页面。
 - (void)viewDidLoad

    Array=[[NSMutableArray alloc]init];
    [Array1 addObject:@"A",@"B",@"C",nil];

 -(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
 Static NSString *cellIdentifier=@"cell";
    cell=[tbView dequeueReusableCellWithIdentifier:cellIdentifier];
    if(cell==nil)
    {
        cell=[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }

     if(tableView==self.tbView)
    {
         cell.textLabel.text=[Array objectAtIndex:indexPath.row];
    } 
    cell.textLabel.font=[UIFont boldSystemFontOfSize:14];
    return cell;
}
 -(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
 if(tableView==self.tbView)
    { 
        return [Array count];
    }
//when select the tableview cell want you want set codes here
 -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

    {
}
{