objective c - UITextField keyboard dismiss on button click to UIApplication method -
i'm going storyboard uisplitviewcontroller in xib. want logout of storyboard view, bring me uisplitviewcontroller. in storyboard controller, have uitextfield. set doesn't dismiss after press enter. however, stays open when switch splitviewcontroller, don't want because want logout.
logout button
uibarbuttonitem *logoutbutton = [[uibarbuttonitem alloc] initwithtitle:@"log out" style:uibarbuttonitemstyleplain target:self action:@selector(confirmlogout)];
method bring uisplitviewcontroller
- (void)alertview:(uialertview *)alertview willdismisswithbuttonindex:(nsinteger)buttonindex { if (alertview.tag==tag_dev){ if (buttonindex) { [[[uiapplication sharedapplication] delegate] performselector:@selector(gotosplitviewcontroller)]; } else { [self.navigationcontroller popviewcontrolleranimated:yes]; }} }
method gotosplitviewcontroller in delegate:
-(void)gotosplitviewcontroller{ self.window = [[uiwindow alloc] initwithframe:[[uiscreen mainscreen] bounds]]; listviewcontroller *listvc = [[listviewcontroller alloc] initwithstyle:uitableviewstyleplain]; uinavigationcontroller *listnc = [[uinavigationcontroller alloc] initwithrootviewcontroller:listvc]; assignedviewcontroller *assignedvc = [[assignedviewcontroller alloc] initwithnibname:@"assignedviewcontroller" bundle:nil]; uinavigationcontroller *assignednc = [[uinavigationcontroller alloc] initwithrootviewcontroller:assignedvc]; //assign views new nav view controllers splitviewcontroller = [[uisplitviewcontroller alloc] init]; splitviewcontroller.delegate = assignedvc; splitviewcontroller.viewcontrollers = @[listnc, assignednc]; listvc.detailviewcontroller = assignedvc; [[self window] setrootviewcontroller:splitviewcontroller]; self.window.backgroundcolor = [uicolor whitecolor]; [self.window makekeyandvisible]; }
my uitextfield
self.textbox = [[uitextfield alloc] initwithframe: cgrectmake(10, 660, 750, 90)]; self.textbox.backgroundcolor = [uicolor colorwithred:(209/255.0) green:(236/255.0) blue:(232/255.0) alpha:1]; self.textbox.returnkeytype = uireturnkeysend; self.textbox.delegate = self; [self.view addsubview:self.textbox];
i've tried resignfirstresponder if various places, including adding
- (void)viewwilldisappear:(bool)animated { [self.textbox resignfirstresponder]; }
however, none of them work. how keyboard disappear after views change?
i set
self.chatbox.delegate=nil;
in methods switch views
Comments
Post a Comment