ios - textFieldShouldReturn does not get called (textField loaded programmatically) -
i'm loading -uitextfield
programmatically , trying make keyboard go down once click on 'search'.
i declare -uitextfeild
inside .m file uitextfield *searchtextfield;
inside .h file indeed declare -uitextfield
's delegate
@interface firstchannel : uiviewcontroller<lbyoutubeplayercontrollerdelegate, uitableviewdelegate,uitableviewdatasource, nsxmlparserdelegate, uitextfielddelegate, avplayeritemoutputpulldelegate>{
this how add uitextfield programmatically.
searchtextfield = [[uitextfield alloc] initwithframe:cgrectmake(10, -26, 300, 30)]; searchtextfield.borderstyle = uitextborderstyleroundedrect; searchtextfield.font = [uifont fontwithname:@"heiti tc" size:13]; searchtextfield.autocorrectiontype = uitextautocorrectiontypeno; searchtextfield.clearbuttonmode = uitextfieldviewmodewhileediting; searchtextfield.contentverticalalignment = uicontrolcontentverticalalignmentcenter; searchtextfield.placeholder = @"search on channel"; searchtextfield.borderstyle = uitextborderstylenone;; searchtextfield.textalignment = uitextalignmentcenter; searchtextfield.center = cgpointmake(160, 43); searchtextfield.textcolor = [uicolor colorwithred:(232.0/255.0) green:(232.0/255.0) blue:(232.0/255.0) alpha:(100.0/100.0)]; searchtextfield.clearbuttonmode = uitextfieldviewmodenever; searchtextfield.returnkeytype = uireturnkeysearch; [searchtextfield setkeyboardappearance:uikeyboardappearancealert]; [self.view.window addsubview:searchtextfield]; [searchtextfield becomefirstresponder];
i added delegate inside -viewdidload
searchtextfield.delegate = self;
however when click on "search" on keyboard nothing happens. i'm unsure why that's happening i've debugged logging once hit returns nothing happens.
call searchtextfield.delegate
after create , setup text field.
Comments
Post a Comment