DownViewController.m 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. //
  2. // DownViewController.m
  3. // FreeMusic
  4. //
  5. //
  6. #import "DownViewController.h"
  7. #import "DBDaoHelper.h"
  8. #import "FMMusicViewController.h"
  9. #import "MusicModel.h"
  10. @interface DownViewController ()
  11. {
  12. NSArray * array;
  13. }
  14. @end
  15. @implementation DownViewController
  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 =nil;// [UIImage imageNamed:@"nav_backbtn.png"];
  23. self.navigation.rightImage = nil;
  24. self.navigation.navigaionBackColor = [UIColor colorWithRed:192.0f/255.0f green:37.0f/255.0f blue:62.0f/255.0f alpha:1.0f];
  25. _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)];
  26. _tableView.delegate =self;
  27. _tableView.dataSource = self;
  28. [self.view addSubview:_tableView];
  29. }
  30. -(void)viewWillAppear:(BOOL)animated{
  31. array = [DBDaoHelper selectDownMusicWithType:1];
  32. [_tableView reloadData];
  33. }
  34. #pragma mark - Table view data source
  35. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  36. {
  37. //#warning Potentially incomplete method implementation.
  38. // Return the number of sections.
  39. return 1;
  40. }
  41. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  42. {
  43. //#warning Incomplete method implementation.
  44. // Return the number of rows in the section.
  45. return [array count];
  46. }
  47. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  48. {
  49. NSString * dentifier = @"cell";
  50. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dentifier];
  51. if (cell == nil) {
  52. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:dentifier];
  53. }
  54. FMSongListModel * model = [array objectAtIndex:indexPath.row];
  55. cell.textLabel.text = model.title;
  56. return cell;
  57. }
  58. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  59. {
  60. return 44;
  61. }
  62. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  63. {
  64. // NSMutableArray *arr = [[NSMutableArray alloc]init];
  65. // for (NSInteger i = 0; i<array.count; i++) {
  66. // FMSongListModel * model1 = [[FMSongListModel alloc]init];
  67. // MusicModel * musicModel1 = [array objectAtIndex:indexPath.row];
  68. // model1.song_id =musicModel1.songid;
  69. // [arr addObject:model1];
  70. // }
  71. FMSongListModel * model = [array objectAtIndex:indexPath.row];
  72. FMMusicViewController * pushController = [FMMusicViewController shareMusicViewController];
  73. pushController.songListModel = model;
  74. pushController.array = array;
  75. pushController.index = indexPath.row;
  76. pushController.only = NO;
  77. [pushController playMusicWithSongLink:model];
  78. [self.navigationController pushViewController:pushController animated:YES];
  79. }
  80. /*
  81. #pragma mark - Navigation
  82. // In a storyboard-based application, you will often want to do a little preparation before navigation
  83. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  84. // Get the new view controller using [segue destinationViewController].
  85. // Pass the selected object to the new view controller.
  86. }
  87. */
  88. @end