0

This is mainly a delegation question because I'm still learning and don't get it. I don't know how to go about creating the delegate I need.

I have a tabbed view controllerwith 2 views, let's call them view 1 and view 2. Then I have a settings view which is not part of the tabbed navigation and accessible by both view 1 and 2.

How do I go about changing the label of a UITabBarItem from the settings view with a text field. You can change a UITabBarItem by setTitle, but I don't know how to set up the delegation.

To give you perspective, View 1 and View 2 are actually Player 1 and Player 2. I want to give the user the option to change the PLayer 1 and PLayer 2 labels to their actual names via the settings screen.

Thanks in advance!

The iOSDev
  • 5,237
  • 7
  • 41
  • 78
sbjluke
  • 309
  • 5
  • 15
  • How are you viewing the Settings View . Is it pushed in the Navigation Controller or is it presented modally ? the code for adding the Settings View would be helpful to help you – M.C. Aug 04 '12 at 14:47
  • The settings View is presented modally. I created the transition using storyboard so I don't know where or if the code exists... I'm still extremely new to this. I really just need to know how to have a text fiel in one view change stuff in a different view. – sbjluke Aug 04 '12 at 22:40

1 Answers1

1

Add the following code in the Settings View Controller (that is presented modally) and call it when you need to change the text field of one of the tabbaritems.

UITabBarController  *tabBarController =(UITabBarController *)[self presentingViewController];
NSArray *tabBarItems =[tabBarController.tabBar items];
UITabBarItem *barItem1=[tabBarItems objectAtIndex:0 ]; // or 1
barItem1.title=@"NewName";
M.C.
  • 1,765
  • 3
  • 29
  • 31