Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add a UITextField #39

Open
rimagahwa opened this issue Oct 19, 2017 · 0 comments
Open

How to add a UITextField #39

rimagahwa opened this issue Oct 19, 2017 · 0 comments

Comments

@rimagahwa
Copy link

I want the user to enter a value into a UITextField after the + button is clicked,
I tried to implement methods that are similar to setting the setButtonsImages

I wrote the following methods in the Demo :
//in LGPlusButtonsView.m

- (void)setTextsField:(UITextField *)field forState:(UIControlState)state forOrientation:(LGPlusButtonsViewOrientation)orientation
{
    for (LGPlusButton *button in _buttonsArray)
        [button setTextField:field forState:state forOrientation:orientation];
    
    [self setNeedsLayout];
}

- (void)setTextsFields:(NSArray *)fields forState:(UIControlState)state
       forOrientation:(LGPlusButtonsViewOrientation)orientation
{
    NSAssert(_buttonsArray.count == fields.count, kLGPlusButtonsViewAssertionWarning(@"fields"));
    
    for (NSUInteger i=0; i<_buttonsArray.count; i++)
        if ([fields[i] isKindOfClass:[UITextField class]])
            [_buttonsArray[i] setTextField:fields[i] forState:state forOrientation:orientation];
    
    [self setNeedsLayout];
}

// in LGPlusButton.m

@property (strong, nonatomic) NSMutableDictionary *fieldsDictionary;
- (void)setTextField:(UITextField *)field forState:(UIControlState)state forOrientation:(LGPlusButtonsViewOrientation)orientation
{
    [_fieldsDictionary setObject:field forKey:[LGPlusButtonsViewShared stringFromState:state andOrientation:orientation]];
    
    if (orientation == LGPlusButtonsViewOrientationAll)
    {
        [_fieldsDictionary setObject:field forKey:[LGPlusButtonsViewShared stringFromState:state andOrientation:LGPlusButtonsViewOrientationPortrait]];
        [_fieldsDictionary setObject:field forKey:[LGPlusButtonsViewShared stringFromState:state andOrientation:LGPlusButtonsViewOrientationLandscape]];
    }
    
    [self setNeedsLayout];
}

this is how I used them
//in PlusScrollViewController.m

 UITextField *uit=[UITextField alloc];
    uit.text=@"Enter Mobile Number";
    uit.minimumFontSize=20;
    [_plusButtonsViewMain setTextsField:uit
                                forState:UIControlStateNormal
                          forOrientation:LGPlusButtonsViewOrientationAll];

the app runs but I don't see the label at all

can you please help me out? if it can be done in another way such as in opening up another View please provide the instructions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant