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.
-
Can you please let me know what message you are getting in log when you app crashes – Pandey_Laxman Aug 21 '12 at 06:24
-
Firstly I have received this message in log " -[__NSCFType first:]: unrecognized selector sent to instance 0x6a155d0" but now I am not receiving any message. And app crash. – SKMAISM Aug 21 '12 at 06:43
-
Please check that you have proper connection to your uibutton. – Pandey_Laxman Aug 21 '12 at 06:46
2 Answers
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 ...

- 31
- 4
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];

- 3,889
- 2
- 21
- 39