How to call a method and set a variable from subview?
hi all,
i have a viewcontroller, im adding a subviewcontroller to it. this subviewcontroller use a subview (subclassed UIView). there is a button in subview.
if the user press the button, i want to set a varibale in Mainviewcontroller, then call RefreshPage method.
i am adding subview controller 3 different viewcontrollers (like mainviewcontroller).
how can i set xyzID then call RefreshPage method ?
i think i should use protocol or delegate.
thanks in advance.
"Each custom view controller object you create is responsible for managing exactly one screen’s worth of content. The one-to-one correspondence between a view controller and a screen is a very important consideration in the design of your application. You should not use multiple custom view controllers to manage different portions of the same screen. Similarly, you should not use a single custom view controller object to manage multiple screens worth of content."
If for some reason you wanted to do that - you could create a protocol for a delegate to implement that the subview controller would invoke the delegate when things of interest happen.
"Each custom view controller object you create is responsible for managing exactly one screen’s worth of content. The one-to-one correspondence between a view controller and a screen is a very important consideration in the design of your application. You should not use multiple custom view controllers to manage different portions of the same screen. Similarly, you should not use a single custom view controller object to manage multiple screens worth of content."
If for some reason you wanted to do that - you could create a protocol for a delegate to implement that the subview controller would invoke the delegate when things of interest happen.
yes i know it, thats why i said i should use protocol or delegate.
what do you advise if you use same button series (in a scrollview)on the top of your 3 viewcontrollers? buttons tag and title's are different for viewcontrollers. thats why i separated buttons into a subview and wrote sub viewcontroller.
i dont how to use protocols.
yes i know it, thats why i said i should use protocol or delegate.
what do you advise if you use same button series (in a scrollview)on the top of your 3 viewcontrollers? buttons tag and title's are different for viewcontrollers. thats why i separated buttons into a subview and wrote sub viewcontroller.
i dont how to use protocols.
IMHO, you are close but instead of a sub viewcontroller - you should just subclass UIView. Call it ScrollButtonView or something. Design a protocol for delegates to implement to be informed of button presses. Register your View Controller as the delegate. This is how UITableView works.
IMHO, you are close but instead of a sub viewcontroller - you should just subclass UIView. Call it ScrollButtonView or something. Design a protocol for delegates to implement to be informed of button presses. Register your View Controller as the delegate. This is how UITableView works.
everything is ok, but there is no code for "Register your View Controller as the delegate". how to register my ViewController for delegate?
i couldnt register it. i dont know where to.
thats why it doesnt respond the selector. i will use this ScrollButtonView in 3 viewcontrollers. how to register delegate for them?