views:

75

answers:

3

I wanted to make a ViewController that had some text editing functionality I wanted through out my application. So, I did this.

 #import <UIKit/UIKit.h>


@interface superViewController : UIViewController
      <UITextFieldDelegate>{

    //these are instance variables, remember them?
    CGFloat animatedDistance;

}

@end

Then, I added the implementation (not shown in these stubs)

#import "superViewController.h"


@implementation superViewController

static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3;
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2;
static const CGFloat MAXIMUM_SCROLL_FRACTION = 0.8;
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216;
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 162;


- (void)textFieldDidBeginEditing:(UITextField *)textField
{

//code commented out for shortness. This work by itself. }

- (void)textFieldDidEndEditing:(UITextField *)textField
{
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField
{
}

Then, I wanted to try it out. So I made a subclass of it as shown here.

@interface salesViewController : superViewController  {

I was expecting the text editing capabilities of superViewController to be in salesViewController, but they are not. I am not sure why or to fix.

Thanks in advance.

+1  A: 

The terminology of your question is a bit confusing. You are creating a subclass of "UIViewController" which you are calling "super". This class may be great, but it is not the super class of UIViewController, it is a subclass.

Yes, your subclass of this subclass will inherit all of the methods and capabilities of "superViewController", so there is nothing in the very little which you have shown which is incorrect as far as that goes.

Do you need to subclass superViewController or perhaps just use an instance of it?

Devin Ceartas
A: 

No, I need a sub-class of it. I expected that the following code would be called. It was not. I don't understand. This method is in the master subclass and I have inherited from it and called it salesView. When this view is loaded, and we enter a text field, I expect this console message to be displayed. It is my understanding that salesView would inherit all the methods of the master class.

- (void)textFieldDidBeginEditing:(UITextField *)textField
{

NSLog(@"Here we are...");
}
jp chance
+2  A: 

Did you set the delegate of the UITextField to be the instance of salesView?

gerry3
[field setDelegate:self];This did it. Thank you.
jp chance