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
countriesCanada
和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
{
}
{