0

So I want to make an iPhone app in which there are two views connected by UINavigationController. Let's say that the first view is ViewA and it's the initial view when the app is launched. Then ViewA segues to ViewB which is the other view. There is a UIButton A and a UILabel A on ViewA and the UIButton A segues to ViewB (i.e. when pressing the button, the user is shown ViewB. In ViewB, there is also a UIButton B that, when pressed, can update the UILabel A in ViewA. (In fact, there should be many UIButton Bs in ViewB but let's just say one for simplicity. That's what I want to achieve and here are what I've done.

I've created the two views and a generic UINavigationController and rooted ViewA to it so the initial view is correctly shown when the app is launched.

I've set up the UILabel A and UIButton A in ViewA and connect the UILabel A as an outlet property to ViewAViewController.

I've imported ViewAViewControllerA in ViewAViewControllerB.

I've segued (push mode) UILabel A on ViewA to View B and it works as intended.

I also know how to update UILabelA in ViewAViewController by using self.UILabelA.text but I can't do it on ViewBViewController because I can't call self and I don't know the name of the object of ViewAViewController. That is: I think I should use ?.UILabelA.text but I don't know what should be put to replace ?.

By the way, I'm using XCode 4.6 and development for iOS 6 with the storyboard mode.

Can anyone help me?

zyl1024
  • 690
  • 1
  • 9
  • 23
  • Daughter!!! I always read as son or child. Now you started to identify SEX in Inheritance :) – Anoop Vaidya Mar 03 '13 at 03:34
  • Oh yes, it should be child. I don't know what it should be called and I just brought the idea in inheritance to it. I'm going to change it, haha. – zyl1024 Mar 03 '13 at 03:37
  • If you have tried to search you could have found dozens of answers for similar questions, and I am sorry I have to vote to close as Dupe. – Anoop Vaidya Mar 03 '13 at 03:42

1 Answers1

2

Your main problem is to access object of ClassA from ClassB.

Here are a lot of ways, and answers here, to do :

Update a label through button from different view

Xcode - update ViewController label text from different view

Setting label text in another class

Set label on another view to stored NSDate

Community
  • 1
  • 1
Anoop Vaidya
  • 46,283
  • 15
  • 111
  • 140