SearchViewController.m 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. //
  2. // SearchViewController.m
  3. // FreeMusic
  4. //
  5. //
  6. #import "SearchViewController.h"
  7. #import "DBDaoHelper.h"
  8. #import "FMMusicViewController.h"
  9. #import "MusicModel.h"
  10. @interface SearchViewController ()
  11. {
  12. NSArray * array;
  13. }
  14. @end
  15. @implementation SearchViewController
  16. - (void)viewDidLoad {
  17. [super viewDidLoad];
  18. // Do any additional setup after loading the view.
  19. self.navigation.title = @"搜索列表";
  20. [self.navigationController setNavigationBarHidden:YES animated:NO];
  21. self.view.backgroundColor = [UIColor whiteColor];
  22. self.navigation.leftImage = [UIImage imageNamed:@"nav_backbtn.png"];//nil;//
  23. self.navigation.rightImage = nil;
  24. // self.navigation.headerImage = [UIImage imageNamed:@"nav_canadaicon.png"];
  25. self.navigation.navigaionBackColor = [UIColor colorWithRed:192.0f/255.0f green:37.0f/255.0f blue:62.0f/255.0f alpha:1.0f];
  26. _tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, self.navigation.size.height+self.navigation.origin.y, self.view.size.width, self.view.size.height-self.navigation.size.height-48.5f)];
  27. _tableView.delegate =self;
  28. _tableView.dataSource = self;
  29. // _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  30. [self.view addSubview:_tableView];
  31. array = [DBDaoHelper selectDownMusicWithName:self.nameMusic];
  32. }
  33. #pragma mark - Table view data source
  34. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  35. {
  36. //#warning Potentially incomplete method implementation.
  37. // Return the number of sections.
  38. return 1;
  39. }
  40. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  41. {
  42. //#warning Incomplete method implementation.
  43. // Return the number of rows in the section.
  44. return [array count];
  45. }
  46. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  47. {
  48. NSString * dentifier = @"cell";
  49. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dentifier];
  50. if (cell == nil) {
  51. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:dentifier];
  52. }
  53. FMSongListModel * model = [array objectAtIndex:indexPath.row];
  54. cell.textLabel.text = model.title;
  55. return cell;
  56. }
  57. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  58. {
  59. return 44;
  60. }
  61. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  62. {
  63. // MusicModel * musicModel = [array objectAtIndex:indexPath.row];
  64. //
  65. // FMMusicViewController * pushController = [FMMusicViewController shareMusicViewController];
  66. // // pushController.songListModel = model;
  67. // // pushController.array = array;
  68. // // pushController.index = indexPath.row;
  69. // FMSongListModel *model = [[FMSongListModel alloc]init];
  70. // model.song_id =musicModel.songid;
  71. // pushController.only = YES;
  72. // [pushController playMusicWithSongLink:model];
  73. // [self.navigationController pushViewController:pushController animated:YES];
  74. NSMutableArray *arr = [[NSMutableArray alloc]init];
  75. for (NSInteger i = 0; i<array.count; i++) {
  76. FMSongListModel * model1 = [[FMSongListModel alloc]init];
  77. MusicModel * musicModel1 = [array objectAtIndex:indexPath.row];
  78. model1.song_id =musicModel1.songid;
  79. [arr addObject:model1];
  80. }
  81. FMSongListModel * model = [array objectAtIndex:indexPath.row];
  82. FMMusicViewController * pushController = [FMMusicViewController shareMusicViewController];
  83. pushController.songListModel = model;
  84. pushController.array = arr;
  85. pushController.index = indexPath.row;
  86. pushController.only = NO;
  87. [pushController playMusicWithSongLink:model];
  88. [self.navigationController pushViewController:pushController animated:YES];
  89. }
  90. - (void)didReceiveMemoryWarning {
  91. [super didReceiveMemoryWarning];
  92. // Dispose of any resources that can be recreated.
  93. }
  94. /*
  95. #pragma mark - Navigation
  96. // In a storyboard-based application, you will often want to do a little preparation before navigation
  97. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  98. // Get the new view controller using [segue destinationViewController].
  99. // Pass the selected object to the new view controller.
  100. }
  101. */
  102. @end