user2082436
user2082436

Reputation: 11

Creation of UIButton inside UITextfield

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

Answers (3)

damithH
damithH

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

fibnochi
fibnochi

Reputation: 1113

You can achieve what you without using UIButton. Use UITextField's delegate methods for this. in- (BOOL)textFieldShouldBeginEditing:(UITextField *)textFieldreturn 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

Uma rajendran
Uma rajendran

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

Related Questions