2010-09-07 67 views
0

如果iPhone中的结果为零,则无法显示全部信息。如何在iphone sdk中使用“titleForHeaderInSection”方法显示大文本?

- (的NSString *)的tableView:(UITableView的*)的tableView titleForHeaderInSection:(NSInteger的)部分 { 如果([customerList计数] == 0){ 回报 @“找不到任何医生用你的搜索。请再试一次。”; } return @“”; }

我声明了表如下 myTableView = [[UITableView的页头] initWithFrame:方法CGRectMake(0,0,320370)样式:UITableViewStylePlain];

在这里我可以显示文本upto ...“找不到任何医生与你......”我如何显示全部或全部信息,请建议解决方案。 感谢你, Madan Mohan

回答

1
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 

试用此委托,并通过与多线标签视图..它会工作。 ..

编码快乐......

+0

你可以给更多的细节 – 2010-09-07 07:41:40

+0

在上面的委托方法采取多行标签,并将其添加到视图。两者都必须具有透明背景。然后在该标签中写下您的文字,并返回上述代表的视图......希望现在清楚。 – 2010-09-07 08:25:12

+0

这有效,但它与默认视图不一样。 – moger777 2015-03-10 18:35:11

1

方法(NSInteger)numberOfSectionsInTableView提供了当前UTableView数据源中存在多少节。

如果您的数据源为空,它将提供“0”。因此,您的titleForHeaderInSection方法将永远不会被调用,因为该零。

,如果你真的想显示节头内部的消息,尝试这样的事情:

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView { 
    if([customerList count == 0]) return 1; 
    else return [[customerList getSections] count]; // or how ever you get the total of sections in your datasource 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
    if([customerList count] == 0) return 0; 
    else return [[customerList getSection:section] count] // or whatever you have implemented :) 
} 
+0

OU,猜你将不得不使用Suriyas我的回答的组合;) – manu 2010-09-07 06:40:43

+0

MM不希望使用多个部分,他只想把第t他的sectionheader的分机的大,它给出...如果使用默认.. – 2010-09-07 12:51:27

相关问题