Recycle the keyboard by clicking on the space

Source: Internet
Author: User

One:

Effect Description: Click on the blank space to quickly recycle the keyboard

Two: Engineering drawings

Three: Code area

AppDelegate.h

#import <UIKit/UIKit.h>@interface appdelegate:uiresponder <UIApplicationDelegate>  *window; @end

Appdelegate.m

#import "AppDelegate.h"#import "RootViewController.h"@interfaceappdelegate ()@end@implementationappdelegate- (void) dealloc{Self.window=Nil; [Super Dealloc];}-(BOOL) Application: (UIApplication *) application didfinishlaunchingwithoptions: (Nsdictionary *) launchoptions {Self.window=[[[UIWindow alloc] initwithframe:[[uiscreen mainscreen] bounds]] autorelease]; //Override point for customization after application launch.Rootviewcontroller *rootview =[[Rootviewcontroller alloc] init]; Uinavigationcontroller*NAVIGATIONVC =[[Uinavigationcontroller Alloc]initwithrootviewcontroller:rootview]; Self.window.rootViewController=NAVIGATIONVC;        [Rootview release];        [NAVIGATIONVC release]; Self.window.backgroundColor=[Uicolor Whitecolor];    [Self.window makekeyandvisible]; returnYES;}@end

RootViewController.h

#import <UIKit/UIKit.h>@interface  rootviewcontroller:uiviewcontroller@end 

Rootviewcontroller.m

#import "RootViewController.h"@interfaceRootviewcontroller () @property (nonatomic, retain) Uitextfield*Text1, @property (nonatomic, retain) Uitextfield*Text2, @property (nonatomic, retain) Uitextfield*Text3;@end@implementationRootviewcontroller- (void) viewdidload {[Super viewdidload]; //Do any additional setup after loading the view.[self showtext];}

#pragma mark-Create a control
- (void) Showtext {self.text1= [[Uitextfield alloc] Initwithframe:cgrectmake ( -, -,260, +)]; _text1.borderstyle=2; Self.text2= [[Uitextfield alloc] Initwithframe:cgrectmake ( -, the,260, +)]; _text2.borderstyle=2; Self.text3= [[Uitextfield alloc] Initwithframe:cgrectmake ( -, -,260, +)]; _text3.borderstyle=2;        [Self.view Addsubview:_text1];        [Self.view ADDSUBVIEW:_TEXT2];        [Self.view ADDSUBVIEW:_TEXT3];        [_text1 release];        [_text2 release]; [_text3 release];}

#pragma mark-The core code of the recovery keyboard

-(void) Touchesbegan: (Nsset *) touches withevent: (uievent *)event  {        [self.text1 Resignfirstresponder];        [Self.text2 Resignfirstresponder];        [Self.text3 Resignfirstresponder];    } -(void) didreceivememorywarning {    [super didreceivememorywarning];     // Dispose of any resources the can be recreated. }@end

Recycle the keyboard by clicking on the space

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.