------ 文章開始 ------

#import "table2ViewController.h"

@interface table2ViewController ()
@end

@implementation table2ViewController
@synthesize cellData2;
//@synthesize cell;


- (id)initWithStyle:(UITableViewStyle)style
{
    self = [super initWithStyle:style];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    self.title =cellData2;
    DatabaseHelper *helper = [[DatabaseHelper alloc] init];
    titles = [helper categories];
    searchResults = [NSMutableArray new];
    one = [NSMutableArray new];
    two = [NSMutableArray new];
    three = [NSMutableArray new];
    four = [NSMutableArray new];
    five = [NSMutableArray new];
    six = [NSMutableArray new];
    seven = [NSMutableArray new];
    [searchResults removeAllObjects];
    [searchResults addObjectsFromArray:titles];
    [searchResults filterUsingPredicate:[NSPredicate predicateWithFormat:@"SELF contains[c] %@",cellData2]];
    for(int i=0;i<searchResults.count;i++)
    {
        [one addObject:[[[searchResults objectAtIndex:i] componentsSeparatedByString: @"█"] objectAtIndex: 0]];
        [two addObject:[[[searchResults objectAtIndex:i] componentsSeparatedByString: @"█"] objectAtIndex: 1]];
        [three addObject:[[[searchResults objectAtIndex:i] componentsSeparatedByString: @"█"] objectAtIndex: 2]];
        [four addObject:[[[searchResults objectAtIndex:i] componentsSeparatedByString: @"█"] objectAtIndex: 3]];
        [five addObject:[[[searchResults objectAtIndex:i] componentsSeparatedByString: @"█"] objectAtIndex: 4]];
        [six addObject:[[[searchResults objectAtIndex:i] componentsSeparatedByString: @"█"] objectAtIndex: 5]];
        [seven addObject:[[[searchResults objectAtIndex:i] componentsSeparatedByString: @"█"] objectAtIndex: 6]];
    }
}

- (void)viewDidUnload
{
    [super viewDidUnload];
    titles = nil;
    searchResults = nil;
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    NSInteger rows = 0;
    rows = [searchResults count];
    return rows;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSString *name;
    static NSString *CellIdentifier = @"SerchCell";
    
    //cell = nil;
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"SerchCell"];
    //cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:@"SerchCell"];
    if(cell==nil)
    {
        cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];

    }
    //cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
    //cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;

    
    name=[[four objectAtIndex:[indexPath row]] stringByAppendingString:@"  "];
    cell.textLabel.text = [three objectAtIndex:[indexPath row]];
    cell.detailTextLabel.text=[name stringByAppendingString:[six objectAtIndex:[indexPath row]]];
    name=[[four objectAtIndex:[indexPath row]] stringByAppendingString:@".jpg"];
    cell.imageView.image = [UIImage imageNamed:name];
    
    return cell;
    
}


/*
// Override to support conditional editing of the table view.
- (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the specified item to be editable.
    return YES;
}
*/

/*
// Override to support editing the table view.
- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath
{
    if (editingStyle == UITableViewCellEditingStyleDelete) {
        // Delete the row from the data source
        [tableView deleteRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationFade];
    }   
    else if (editingStyle == UITableViewCellEditingStyleInsert) {
        // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
    }   
}
*/

/*
// Override to support rearranging the table view.
- (void)tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath
{
}
*/

/*
// Override to support conditional rearranging of the table view.
- (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Return NO if you do not want the item to be re-orderable.
    return YES;
}
*/

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    // Navigation logic may go here. Create and push another view controller.
    /*
     <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];
     // ...
     // Pass the selected object to the new view controller.
     [self.navigationController pushViewController:detailViewController animated:YES];
     */
}

@end
------ 文章結尾 ------

[複製網址] [開新視窗] [檢舉短網址] [QR條碼]

服務條款 - 加入會員(免費) - 回報問題網址 - 聯絡偶們 -

© 2025 PPT.cc