SelectTypeViewController.m 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. //
  2. // SelectTypeViewController.m
  3. // FreeMusic
  4. //
  5. //
  6. #import "SelectTypeViewController.h"
  7. #import "DBDaoHelper.h"
  8. @interface SelectTypeViewController ()
  9. {
  10. NSArray * array;
  11. }
  12. @end
  13. @implementation SelectTypeViewController
  14. - (void)viewDidLoad {
  15. [super viewDidLoad];
  16. // Do any additional setup after loading the view from its nib.
  17. [self.navigationController setNavigationBarHidden:YES animated:NO];
  18. self.view.backgroundColor = [UIColor whiteColor];
  19. self.navigation.leftImage = [UIImage imageNamed:@"nav_backbtn.png"];
  20. // self.navigation.headerImage = [UIImage imageNamed:@"nav_canadaicon.png"];
  21. // self.navigation.title = [NSString stringWithFormat:@"%@(歌曲%d)",_singerModel.name,_singerModel.songs_total];
  22. self.navigation.navigaionBackColor = [UIColor colorWithRed:192.0f/255.0f green:37.0f/255.0f blue:62.0f/255.0f alpha:1.0f];
  23. _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)];
  24. _tableView.delegate =self;
  25. _tableView.dataSource = self;
  26. // _tableView.separatorStyle = UITableViewCellSeparatorStyleNone;
  27. [self.view addSubview:_tableView];
  28. array = [DBDaoHelper myType];
  29. }
  30. - (void)viewWillAppear:(BOOL)animated {
  31. self.parentViewController.tabBarController.tabBar.hidden = YES;
  32. }
  33. -(void)viewWillDisappear:(BOOL)animated {
  34. self.parentViewController.tabBarController.tabBar.hidden = NO;
  35. }
  36. #pragma mark - Table view data source
  37. - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
  38. {
  39. //#warning Potentially incomplete method implementation.
  40. // Return the number of sections.
  41. return 1;
  42. }
  43. - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
  44. {
  45. //#warning Incomplete method implementation.
  46. // Return the number of rows in the section.
  47. return [array count];
  48. }
  49. - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
  50. {
  51. NSString * dentifier = @"cell";
  52. UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:dentifier];
  53. if (cell == nil) {
  54. cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:dentifier];
  55. }
  56. NSString * model = [array objectAtIndex:indexPath.row];
  57. cell.textLabel.text = model;
  58. return cell;
  59. }
  60. -(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
  61. {
  62. return 44;
  63. }
  64. -(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  65. {
  66. if ([self.delegate respondsToSelector:@selector(selectTypeViewController:selectType:)]) {
  67. [self.delegate selectTypeViewController:self selectType:indexPath.row];
  68. [self.navigationController popViewControllerAnimated:YES];
  69. }
  70. }
  71. - (void)didReceiveMemoryWarning {
  72. [super didReceiveMemoryWarning];
  73. // Dispose of any resources that can be recreated.
  74. }
  75. /*
  76. #pragma mark - Navigation
  77. // In a storyboard-based application, you will often want to do a little preparation before navigation
  78. - (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
  79. // Get the new view controller using [segue destinationViewController].
  80. // Pass the selected object to the new view controller.
  81. }
  82. */
  83. @end