I'm using Storyboards and iOS 6.1, I'm initiating a view like this:
PropertiesViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"Properties"]; PropertiesViewController has a 60px height viewn an including some labels and more. I want to add these views to another ScrollView as subview. Here what I'm doing:
controller.leftLabel.text = @"Test"; controller.background.image = [UIImage imageNamed: @"someimage.png"]; controller.view.frame = CGRectMake(0, currentHeight, controller.view.frame.size.width, cellHeight); [self.scrollView addSubview: controller.view]; leftLabel is a UILabel and backgorund is a UIImageView.The problem is none of view's elements are not updating outside of PropertiesViewController. addSubview: is just adding as how its created, not allow to configure.
I've already checked NSNotificationCenter approach, if I'm not wrong it's not about updating instances. And I've also already added a method to receiver class to update labels inside of PropertiesViewController. That even did not worked.
What am I doing wrong?
Note: You may ask that why just I'm not using a TableView. There has to be more dynamic resources and their besides are not clear. There is also one thing that TableView is not possible with ScrollView, in some cases I've never use a TableView so scrollview will manage scroll.
Any help would be great.
EDIT:
According to Kalpesh's answer here what I did:
In my sender view controller:
PropertiesViewController *controller = [self.storyboard instantiateViewControllerWithIdentifier:@"Properties"]; [[NSNotificationCenter defaultCenter] postNotificationName:@"update" object:@"Test string"]; controller.view.frame = CGRectMake(0, currentHeight, controller.view.frame.size.width, cellHeight); // not sure how but I can change frame successfully. [self.scrollView addSubview: controller.view]; Here is receiver:
- (void)viewDidLoad { [super viewDidLoad]; NSLog(@"Called"); // Working fine [[NSNotificationCenter defaultCenter] removeObserver:self]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(changetext:) name:@"update" object:nil]; //even if set some object, nothing changed } - (void) changetext:(NSNotification *)notification { NSLog(@"Received"); // Not working leftLabel.text = [notification object]; }