开发者

How to add action to one dynamic button in one UIView Control to move back to UIViewController

In my application, i am using UIViewController and dynamically created UIView.In that view dynamically created subviews(UIButton and PickerViewController)..I开发者_运维知识库 want to display selected picker view value in a label control in UIViewController... How to add action to this button to move back to UIViewController...


You can either pass the reference of the UIViewCOntroller to the subview or you can create delegate methods for the subview.

Method 1 :

//below code is written in your UIViewController

/*You should write the implementation of initWithFrame:viewController: in UIVIEW

CustomUIView *youSubView = [[CustomUIView alloc]initWithFrame : yourFrame viewController:self];

//below code is in CustomUIView

- (id) initWithFrame :(CGRect)frame viewController:(id)vc
{
....
UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
[btn addTarget:vc action:methodinVc forControlEvents:UIControlEventTouchUpInside]; 

}

Method 2 :

Make protocol and delegate in UIView and make the UIViewController to respond to the delegate calls

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜