Custom iOS Techniques iOS

I have a CaptureDataVC view CaptureDataVC and a custom KeyboardView view.

KeyboardView has all the init functions necessary to work as needed:
-(id)initWithCoder:(NSCoder *)aDecoder and -(id)initWithFrame:(CGRect)frame

In the CaptureDataVC xib file, I have a UIView with a custom KeyboardView class.

The view looks just fine. The problem is that I cannot call any of the methods in KeyboardView (it compiles and I don't get any errors, but the methods are not called).

So basically I can not do this:

CaptureDataVC.h

 @property (nonatomic,retain) IBOutlet KeyboardView *keyboardView; 

CaptureDataVC.m

 [self.keyboardView foo]; 

KeyboardView.m

 -(void) foo { NSLog(@"Hello World!"); //Won't print anyting } 

Any ideas?

Edit:

enter image description here

Custom class set to blue.

+6
source share
5 answers

Well, the first questions:

  • Whether the line is [self.keyboardView foo]; ? Put a breakpoint there.
  • If so, is self.keyboardView not zero? When the debugger stopped at a previous breakpoint, enter po self.keyboardView in the debugger to check.

The classic mistake is to assume that self.someView always set. In fact, this will not happen before the view and exits load. See the documentation for viewDidLoad and isViewLoaded .

+7
source

Please check if the property of the KeyboardView property is configured: if the property is zero, nothing will happen

+5
source

There is no need to initialize the user view manually as an added controller. All you have to do is just check where you are calling your own browsing method. It should be called after loading your view. i.e. viewDidLoad or viewWillAppear.

+2
source

In CaptureDataVC.m you must allocate memory for the object as:

 self.keyboardView=[[KeyboardView alloc]init]; 

and calling your method:

 [self.keyboardView foo]; 

he will work.

+1
source

You can achieve the desired result using delegates. Embed the keyboard view delegates in your view manager.

+1
source

All Articles