views:

42

answers:

2

Hi Guys,

I am unable to display the total information if the results are nil in iPhone.

-(NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section { if ([customerList count] == 0) { return @"Could not find any doctor with your search. Please try again."; } return @""; }

I Declared the table as below myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, 320,370) style:UITableViewStylePlain];

Here I can display the text upto ... "Could not find any doctor with your......" How can I show full or total information, Please suggest the solution. Thanking You, Madan Mohan

+1  A: 

the method (NSInteger)numberOfSectionsInTableView delivers how many sections are present in the current UTableView datasource.

if your datasource is empty, it will provide "0". therefore, your titleForHeaderInSection-method will never be called because of that zero.

if you really want to display that message inside a section header, try something like this:

- (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 :)
}
manu
ou, guess you'll have to use a combination of Suriyas and my answer ;)
manu
@manu: MM does not want to use multiple sections he just want to make the text of his sectionheader larger which gives... if used with default..
Suriya
+1  A: 
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section 

Try out this delegate and pass on a view with multilines label.. it will work...

hAPPY cODING...

Suriya
Can u give more details
Madan Mohan
Take a multiline label in the above delegate method and add it to a view. both must have transparent background. then write your text in that label and return the view for the above delegate... hope its now clear.
Suriya