How to make button in child view to update informa

2019-03-06 06:55发布

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?

1条回答
登录 后发表回答