1. Hide the status bar
After iOS upgraded to 7.0, many APIs were abolished, and the original method of hiding the status bar StatusBar was invalidated.
Original plan
[[UIApplication sharedapplication] setstatusbarhidden:yes];
Unfortunately, it worked in later versions, so we can use the new API to implement the purpose of the hidden State column, as follows:
-(BOOL) prefersstatusbarhidden{ return YES;
2. Automatically hide the keyboard and automatically layout
The solution provided here is suitable for any type of keyboard, mainly considering that Numberpad has no return key.
It is also a scheme based on Scrollerview for layout, using the animated effect of Scrollerview.
The code is as follows:
@implementation testviewcontroller-(void) viewdidload { [super viewdidload]; Do any additional setup after loading the view. [_scrollview Addgesturerecognizer:[[uitapgesturerecognizer alloc] initwithtarget:self action: @selector ( Hidekeyboard)]];} -(void) textfielddidbeginediting: (Uitextfield *) textfield{ //keyboard height is 216 [_scrollview setframe:cgrectmake (0, 0, _scrollview.frame.size.width, _scrollview.frame.size.height+216)]; [_scrollview setcontentoffset:cgpointmake (0) animated:yes]; [_scrollview settag:0]; } -(void) hidekeyboard{ if (_scrollview.tag==0) { [_scrollview setcontentoffset:cgpointmake (0, 0) animated:yes ]; [_scrollview setframe:cgrectmake (0, 0, _scrollview.frame.size.width, _scrollview.frame.size.height-216)]; [Self.view Endediting:yes]; [_scrollview settag:1];}}}
iOS Development-Auto-hide keyboard and status bar