Call Method From Another View Controller iOS StoryBoard?

As a workaround, you could set the tag property of the sender in InterfaceBuilder to something, and then just compare sender tag in the addButtonClicked: method. I believe tags are int s.

Up vote 0 down vote favorite share g+ share fb share tw.

I have a table view cell with a button that, when pressed, needs to call the method of a different view controller. I''ve followed this tutorial, which shows one way to get at another view controller in story boards, but it involves hardcoding the position of the view controllers. Anytime I'd change the order of my view controllers, I'd need to update my code, which I know I will mess up.

Here is their method: UITabBarController *tabBarController = (UITabBarController *) self.window. RootViewController; UINavigationController *navigationController = tabBarController viewControllers objectAtIndex:0; PlayersViewController *playersViewController = navigationController viewControllers objectAtIndex:0; playersViewController. Players = players; Yikes, what is that?

! We want to assign the players array to the players property of PlayersViewController so it can use this array for its data source. But the app delegate doesn’t know anything about PlayersViewController yet, so it will have to dig through the storyboard to find it.

This is one of the limitations of storyboards that I find annoying. With Interface Builder you always had a reference to the App Delegate in your MainWindow. Xib and you could make connections from your top-level view controllers to outlets on the App Delegate.

That is currently not possible with storyboards. You cannot make references to the app delegate from your top-level view controllers. That’s unfortunate, but we can always get those references programmatically.

Does anybody know a cleaner way? I tried creating an IBOutlet in my table view cell to the other view controller, but I can't ctrl-click and drag to the other view controller for some reason. I also tried setting the IBAction of my button in my other view controller, but I need to know what row was clicked, and the only information I can get from -(IBAction) addButtonClicked:(id)seder is the sender information, which is just RectButton.

Thanks! Ios xcode uiviewcontroller storyboard link|improve this question asked Oct 20 '11 at 17:36Tyler DeWitt55013 90% accept rate.

As a workaround, you could set the tag property of the sender in InterfaceBuilder to something, and then just compare sender tag in the addButtonClicked: method. I believe tags are ints.

Thanks for the idea. I ended up switching to delegation to take care of it, but the tag is a great idea. Also, I saw in an Apple demo that there is a UIViewController storyboard method that they say is for loading any arbitrary ViewController on the Storyboard.

I'll take a look at that too. But thanks for the idea. I'm sure I'll use it somewhere – Tyler DeWitt Oct 21 '11 at 15:26.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions