2

My iOS app has a UITabBarController with two tabs such as Player and Album ,with Player tab is selected by default and it has a ViewController with an audio player.When Album tab is selected it contains a UINavigationController on which a UITableView is placed,which shows several albums.When a particular album name is selected it pushes to another ViewController showing the songs of that selected album.Now when I select a particular song,I want to pass the song url to the audio player which is found under player tab ,and I want to show the main tabbarcontroller .

For eg : consider the iPhone music player.We go through an album and when we select a song it shows the player screen ,how is it done ?

  • In this line "I want to pass the song url to the audio player which is found under **album** tab ,and I want to show the main tabbarcontroller ", i guess by mean album tab u mean player tab???? – Baby Groot Mar 01 '13 at 11:13
  • 1
    yes , i mean the player tab,my mistake. – user2114872 Mar 01 '13 at 11:20

1 Answers1

0

I guess this should solve your issue self.tabBarController.selectedIndex = indexOfTab;

For further reference

UITabBarController Class Reference

Jump to a specific tab in a UITabBarController

Community
  • 1
  • 1
Baby Groot
  • 4,637
  • 39
  • 52
  • 71
  • I used the above code in my DidSelectRow. After selecting the song it didn't show up the player tab , it was just stuck there . – user2114872 Mar 01 '13 at 11:26
  • You actually have a call to pop to the root view controller. – Baby Groot Mar 01 '13 at 11:30
  • I did like this in my DidSelectRow `NSString *albumURLstring = [addsongstring stringByAppendingString:mp3extension]; viewContObj = [[ViewController alloc]initWithNibName:@"ViewController" bundle:nil]; self.tabBarController.selectedViewController = viewContObj; viewContObj.url =[NSURL URLWithString:albumURLstring]; [viewContObj createStreamer]; [viewContObj playLiveStream:nil];` – user2114872 Mar 01 '13 at 11:31
  • see this link(http://www.ifans.com/forums/threads/overriding-uitabbarcontroller-behavior.209946/), you will understand. – Baby Groot Mar 01 '13 at 11:32
  • After executing my code above . The url get passed and the song is played. But the player under my "player" tab is unaffected and static . Doesn't respond to the passed URL . So that means my player ViewController is not called yet,right? – user2114872 Mar 01 '13 at 11:36
  • if this is the only view in your player tab, then start your player in viewwillappear, it should work once you do that. – Baby Groot Mar 01 '13 at 11:38
  • No change in my output. Where am i going wrong? when I select a item in tableview it is not showing my player controller and the player is not activated . – user2114872 Mar 01 '13 at 11:45