I have 3 class with 3 view controller. And I am adding Second view as a subview in my First View. and In second view there are a button and I want that when I click on that button, a method will called of second view. But my application is crash when I click on that button. Can you help that how I'll perform any event in subview.
How to perform click event in subview button in iphone?
772 views Asked by SKMAISM At
2
There are 2 answers
0
On
you should add your second view like: you should add a uiview IBOutlet on which you show the second View; then make it proprty and add subview of secondView like below;
FirstView.h
@class secondView; { secondView *secondViewObj; }
@property(nonautomic,retain)secondView *secondViewObj;
in the implementation file Firstview.m @synthesize secondViewObj;
then in you viewDidLoad method you have uiview outlet mysecondsubView in the firstView on which you show the second view.
self.mysecondSubView=[[secondView alloc]initWithNibName@"secondView" nibBundle:nil];
remember this: 3 Nested views , No.1 contains NO.2 and NO.2 contains NO.3, you touch the screen, actually No.1 become the first responder, if NO.1's userInteractionEnabled == YES, then NO.2 could get the responder and so on, usually view's userInteractionEnabled is YES, but some are not , like UIImageView ...