Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- NSInteger row = [indexPath row];
- NSInteger section = [indexPath section];
- static NSString *CellIdentifier = @"Student";
- cell = [tv dequeueReusableCellWithIdentifier:CellIdentifier];
- if (cell == nil) {
- cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier] autorelease];
- }
- // Configure the cell
- if([studentsSearch count] > 0) {
- cell.text = (NSString *)[[[studentsSearch objectAtIndex:section] objectAtIndex:row] valueForKey:@"name"];
- cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
- } else {
- if(isSearching == YES)
- cell.text = @"No students available.";
- else
- cell.text = @"No students have been added for this school.";
- cell.font = [UIFont fontWithName:@"Georgia" size:14];
- cell.accessoryType = UITableViewCellAccessoryNone;
- }
- return cell;
- }
- cell.font = [UIFont systemFontOfSize: 14];
- cell.text = (NSString *)[[[...
- cell.accessoryType = ...
- - (UITableViewCell *)tableView:(UITableView *)tv cellForRowAtIndexPath:(NSIndexPath *)indexPath {
- NSInteger row = [indexPath row];
- NSInteger section = [indexPath section];
- static NSString *StudentCellIdentifier = @"Student";
- static NSString *NoneCellIdentifier = @"None";
- // did we find students?
- BOOL found = [studentsSearch count] > 0;
- // get/create correct cell type
- cell = [tv dequeueReusableCellWithIdentifier:(found ? StudentCellIdentifier : NoneCellIdentifier)];
- if (cell == nil) {
- cell = [[UITableViewCell alloc] initWithFrame:CGRectZero
- reuseIdentifier:(found ? StudentCellIdentifier : NoneCellIdentifier)];
- }
- // return a student, or None cell if no studnts found
- if( found )
- {
- cell.text = (NSString *)[[[studentsSearch objectAtIndex:section] objectAtIndex:row] valueForKey:@"name"];
- cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
- }
- else
- {
- if(isSearching == YES)
- cell.text = @"No students available.";
- else
- cell.text = @"No students have been added for this school.";
- cell.font = [UIFont fontWithName:@"Georgia" size:14];
- cell.accessoryType = UITableViewCellAccessoryNone;
- }
- return [cell autorelease];
- }
Add Comment
Please, Sign In to add comment