LGPlusButtonsView
LGPlusButtonsView copied to clipboard
How to add a UITextField
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