0
votes

I use the storyboard seque to modal a UIViewController over my tabbarController. The purpose of the view controller that pops up is to take a few user inputs and return an answer to a label on one of the tab bar views (the one that was selected before the view controller popped up).

In my code I added #import "viewBeforePopup.h" to the poppedUpView.h header file.

Then I create an outlet

IBOutlet viewBeforePopup *view;

The button that triggers the view controller dismal has this code associated with it


NSString *strToSet = textbox.text;

[view.label setText:strToSet];

[self dismissModalViewControllerAnimated:YES];

This use to work for me before storyboard mode. I Should note that the storyboard contains the tab bar controller which is initially loaded and then I added the additional UIViewController.

The view disappears properly and the tab bar view is visible, but the label does not change. I debugged an verified the string that I am trying to assign to the label has a value and it does. It just seems like everything works except for applying the text to the label.

Can anyone please tell me what I am doing wrong with my method or explain the ideal way of doing this since this is probably the wrong way to go about it.

Thank You in advance

2

2 Answers

0
votes

at a guess, it's probably taking a snapshot image of the modal view and animating that off. try something like:

- (void)dismissModal {
  [self dismissModalViewControllerAnimated:YES];
}

....

  NSString *strToSet = textbox.text;
  [view.label setText:strToSet];
  [self performSelector:@selector(dismissModal) withObject:nil afterDelay:0.1];
0
votes

Your need to setup a delegate protocol which would allow the one view controller to write data back to one of the other view controller. Read Understanding Fundamental Design Patterns.

I've searched for a tutorial for you that explains how to implement a delegate design pattern. There are a number of steps involved to make it work. This tutorial contains all the steps.