objective c - Why doesn't my UIKeyboard disappear on resignfirstresponder -


this ridiculous, cant't see whats wrong code. hope can me right. problem when resignfirstresponder fires seems uikeyboard appears, note done button changes ordinary return button on keyboard.

my testviewcontroller.m file

#import <quartzcore/quartzcore.h> #import <uikit/uikit.h> #import "testviewcontroller.h" #define koffset_for_keyboard 216.0 @interface testviewcontroller () {     float increase;     int increases;     uitextview *txt;     uiview *vw;     uiview *tvw;     uitableview *tbl;     uibutton *b; } @end  @implementation testviewcontroller  - (void)viewdidload {     vw =[[uitextview alloc]initwithframe:cgrectmake(0, self.view.frame.size.height-34, 320, 1000)];     vw.backgroundcolor =[uicolor blackcolor];     tbl =[[uitableview alloc]initwithframe:cgrectmake(0, 0, 320, self.view.frame.size.height-34)];     txt =[uitextview new];     txt.frame=cgrectmake(4, 4, 255, 25);     [txt setscrollenabled:no];     txt.contentinset = uiedgeinsetsmake(4, 4, 0, 0);     [tbl setdelegate:self];     [tbl setdatasource:self];     [txt setdelegate:self];     [txt setreturnkeytype:uireturnkeydone];     [self.view addsubview:tbl];     [[txt layer] setcornerradius:2.0f];     [vw addsubview:txt];     [self.view addsubview:vw];     increases = 0;     increase =23;     txt.text =@"give me text...";     b = [uibutton buttonwithtype:uibuttontypecustom];     b.frame = cgrectmake(263, 4, 53, 25);     b.tag =1;     [[b layer] setcornerradius:2.0f];     [[b layer] setmaskstobounds:yes];     [b addtarget:self action:@selector(close:) forcontrolevents:uicontroleventtouchupinside];     [vw addsubview:b];     b.backgroundcolor =[uicolor graycolor];     [super viewdidload];  } - (void)textviewdidendediting:(uitextview *)textview {     [self setviewmovedup:no]; } -(void)textviewdidchange:(uitextview *)textview {     if(increase!=txt.contentsize.height) {         cgrect rect = txt.frame;         rect.size.height = txt.contentsize.height;         textview.frame   = rect;         cgrect brect = b.frame;         if(txt.frame.size.height<25){             cgrect temp = txt.frame;             temp.size.height =25;             txt.frame =temp;         }         brect.origin.y = txt.frame.size.height +4-25;         b.frame = brect;         cgrect arect = self.view.frame;          if(increase < txt.contentsize.height) {             arect.origin.y -= 15;             arect.size.height += 15;             increases =increases+1;         } else {             arect.origin.y += 15;             arect.size.height -= 15;             increases =increases-1;         }         nslog(@"%f",brect.size.height);         self.view.frame = arect;         increase = txt.contentsize.height;     } } -(void)setviewmovedup:(bool)movedup {     [uiview beginanimations:nil context:null];     [uiview setanimationduration:0.25];     cgrect rect = self.view.frame;     if (movedup) {         rect.origin.y -= koffset_for_keyboard;         rect.size.height += koffset_for_keyboard;     } else {         rect.origin.y += koffset_for_keyboard+(increases*15);         rect.size.height -= koffset_for_keyboard+(increases*15);         vw.frame = cgrectmake(0, self.view.frame.size.height-34, 320, 1000);         txt.frame = cgrectmake(4, 4, 255, 25);         increase = 23;         increases = 0;         txt.text=@"";     }     self.view.frame = rect;     [uiview commitanimations]; } - (void)textviewdidbeginediting:(uitextview *)textview {     if  (self.view.frame.origin.y >= 0) {         txt.text =@"";         [self setviewmovedup:yes];     }  } -(void)close:sender {     if(txt.isfirstresponder)         [txt resignfirstresponder]; } - (nsinteger)numberofsectionsintableview:(uitableview *)tableview {     return 100; } - (nsinteger)tableview:(uitableview *)tableview numberofrowsinsection:(nsinteger)section {     return 1; } - (cgfloat)tableview:(uitableview *)tableview heightforrowatindexpath:(nsindexpath *)indexpath {     return 60.0; } - (uitableviewcell *)tableview:(uitableview *)tableview cellforrowatindexpath:(nsindexpath *)indexpath {     static nsstring *cellidentifier = @"cell";     uitableviewcell *cell = [[uitableviewcell alloc]initwithstyle:uitableviewcellstyledefault reuseidentifier:cellidentifier];     cell.textlabel.text = [nsstring stringwithformat:@"%i",indexpath.section];     return cell; } - (void)tableview:(uitableview *)tableview didselectrowatindexpath:(nsindexpath *)indexpath {     if(txt.isfirstresponder)         [txt resignfirstresponder]; } @end    

my testviewcontroller.h file

#import <uikit/uikit.h> @interface testviewcontroller :     uiviewcontroller<uitableviewdatasource,uitableviewdelegate,uitextviewdelegate>   @end 

thanks in advance

you appear have uitextview mean have uiview @ initialization of vw leading having uitextview within uitextview.


Comments

Popular posts from this blog

Perl - how to grep a block of text from a file -

delphi - How to remove all the grips on a coolbar if I have several coolbands? -

javascript - Animating array of divs; only the final element is modified -