Objective c keyboard opens unwillingly

45 views Asked by At

I have a "layer builder" object which creates different views and returns them after initialising them.

The problem is, whenever i press on one of these created views, the keyboard opens up and i can't understand why.

This is how my layer builder is coded:

@interface LayerBuilder : NSObject <VENTokenFieldDelegate, VENTokenFieldDataSource, UITableViewDataSource, UITableViewDelegate>

the VEN stuff is a project i found on github which i'm using, it has text fields used in it in case it matters.

And an example for layer builder usage:

-(void) showEmailCompilationView
{
    lb = [[LayerBuilder alloc] init];
    [lb placeDetailsLayerOnView:self.view withContacts:TRUE withSubject:TRUE withLable:@"Mail"];
    ...
}

and the function being called:

CGRect screenRect = [[UIScreen mainScreen] bounds];

int xOrig = screenRect.origin.x;
int yOrig = screenRect.origin.y;
int xWid = screenRect.size.width;

int yWid = TEXT_FIELD_HEIGHT;

if(ctcs)
{
    yWid += TEXT_FIELD_HEIGHT + TEXT_VIEW_BOUNDRIES * 2;
}

if(subject)
{
    yWid += TEXT_FIELD_HEIGHT + TEXT_VIEW_BOUNDRIES * 2;
}

UIView* viewToAdd = [[UITextView alloc] initWithFrame: CGRectMake(xOrig, yOrig, xWid, yWid)];

viewToAdd.backgroundColor = [UIColor redColor];

[view addSubview:viewToAdd];

return viewToAdd;
}

Nothing fancy as you see.

Now, whenever i press this layer, the keyboard is opened regardless of the fact that this layer is a simple uiview which has nothing to do with the keyboard.

Any idea on where the problem lays?

1

There are 1 answers

0
MDB983 On BEST ANSWER

Formalized Comment;

Casting UITextField as UIView is causing the keyboard to open.

Thanks