我需要在某些情况下显示/隐藏UITableView
。但它有时运行绝对正常。但有时tableView
未被隐藏。在iPhone中隐藏/显示UITableView?
如果数组数据存在我填写它在UITableView.But如果数组为空我显示一个标签文本“数据未找到”..这是完美的工作,但如果我反复这样做然后是越来越显示我的TableView的数据标签文本不隐藏tableView
..Couldn't明白的地方我要去错了..
这是我正在写的代码...
if([arr count]==0)
{
[email protected]"";
lblError = [[UILabel alloc] init];
[lblError setFrame:CGRectMake(0,390,320,200)];
lblError.textAlignment=UITextAlignmentLeft;
lblError.backgroundColor = [UIColor clearColor];
lblError.text = @"Results not found";
lblError.textColor = [UIColor redColor];
lblError.shadowColor = [UIColor blackColor];
lblError.font = [UIFont fontWithName:@"Verdana-Italic" size:15];
[self.view addSubview:lblError];
tableView.hidden=YES;
[tableView removeFromSuperview];
tableView=nil;
}
else
{
sections=[[NSMutableArray alloc] init];
for(int s=0;s<1;s++)
{
NSMutableArray *section=[[NSMutableArray alloc] init];
for(int i=0;i<[arr1 count];i++)
{
Item *item=[[Item alloc] init];
NSString *name=[[arr objectAtIndex:i]objectForKey:@"Name"];
item.Name=name;
[section addObject:item];
}
[sections addObject:section];
}
tableView=[[UITableView alloc]initWithFrame:CGRectMake(0,430,320,200) style:UITableViewStylePlain];
tableView.delegate = self;
tableView.dataSource = self;
[self.view addSubview:tableView];
[tableView release];
}
我做到了,因为你说过。但仍然没有运气 – Honey
你在哪里wri上面的代码? – IronManGill
这个概念是我必须从DatePicker中选择一个日期,如果数据存在,我将在tableview中输入它。否则我将显示一个简单的消息“Data not found”。所以我在这里写它 - (void)DatePickerDoneClick :(id)发送者 {}。它工作绝对正常4至5次。但如果我重复多次,然后tableView不会隐藏和消息显示在tableView上,即一个在另一个..所以我应该怎么做? – Honey