Reputation: 11
i am new to ios development.I want to create UIButton inside UITextfield.When we click on UIButton Uidatepicker appear and when we select date from datepicker the date should display in UitextFiels.I know all logics except insert UiButton inside Uitextfield and Giving action to it.Can any give me the idea.
Thanks, in advance
Upvotes: 1
Views: 526
Reputation: 5178
Add UIButton instance after adding UITextField. the frame of UIButton should be inside the UITextField frames. keep it mind when you add subviews add UIButton after the UITextField adding.
Upvotes: 0
Reputation: 1113
You can achieve what you without using UIButton. Use UITextField's delegate methods for this.
in- (BOOL)textFieldShouldBeginEditing:(UITextField *)textField
return NO and show datePikcer
and when datepicker dismises set the text for UITextFiled. for reference have look at http://developer.apple.com/library/ios/#documentation/uikit/reference/UITextFieldDelegate_Protocol/UITextFieldDelegate/UITextFieldDelegate.html
Upvotes: 1
Reputation: 287
No need of inserting UIbutton in UItextfield. Place uibutton over uitextfield. Just u need to give the same frame for both textfield and button and Make the button as custom button.
Upvotes: 0