欧美一级特黄大片做受成人-亚洲成人一区二区电影-激情熟女一区二区三区-日韩专区欧美专区国产专区

如何解決IOS中NSNotification鍵盤遮擋問題-創(chuàng)新互聯(lián)

這篇文章主要為大家展示了“如何解決IOS中NSNotification鍵盤遮擋問題”,內(nèi)容簡而易懂,條理清晰,希望能夠幫助大家解決疑惑,下面讓小編帶領大家一起研究并學習一下“如何解決IOS中NSNotification鍵盤遮擋問題”這篇文章吧。

創(chuàng)新互聯(lián)公司專注于閬中企業(yè)網(wǎng)站建設,自適應網(wǎng)站建設,成都商城網(wǎng)站開發(fā)。閬中網(wǎng)站建設公司,為閬中等地區(qū)提供建站服務。全流程按需定制制作,專業(yè)設計,全程項目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務

IOS NSNotification 鍵盤遮擋問題的解決辦法

從鍵盤通知中獲得鍵盤尺寸

鍵盤尺寸存在于NSNotification中。

1;在AddDrinkViewController中添加keyboardDidShow和keyboardDidHide方法

2;在viewWillAppear中注冊UIKeyboardDidshowNotification與UIKeyboardDidHideNotification。

3;在viewWillDisappear中取消對所有事件的訂閱注冊

4;在AddDrinkViewController中添加一個Bool成員,跟蹤鍵盤是否可見的狀態(tài)。

//
// ViewController.h
// scrol
//
// Created by gao wuhang on 12-12-5.
// Copyright (c) 2012年 gao wuhang. All rights reserved.
//

#import

@interface ViewController : UIViewController{
  BOOL keyboardVisible;
  UIScrollView *scrollView;
}

- (void)keyboardDidShow: (NSNotification*) notif;
- (void)keyboardDidHide: (NSNotification*) notif;

@property (nonatomic, retain) UIScrollView *scrollView;
@end

 
//
// ViewController.m
// scrol
//
// Created by gao wuhang on 12-12-5.
// Copyright (c) 2012年 gao wuhang. All rights reserved.
//

#import "ViewController.h"

@interface ViewController ()

@end

@implementation ViewController

@synthesize scrollView;

- (void)viewWillAppear:(BOOL)animated{
  [super viewWillAppear:animated];
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidShow:) name:UIKeyboardDidShowNotification object:nil];
  [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardDidHide:) name:UIKeyboardDidHideNotification object:nil];
}

- (void)viewWillDisappear:(BOOL)animated{
  [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void) keyboardDidShow:(NSNotification *)notif {
NSLog(@"%@", @"Received UIKeyboardDidShowNotification");
 
if (keyboardVisible) {
NSLog(@"%@", @"Keyboard is already visible. Ignoring notifications.");
return;
}
 
// The keyboard wasn't visible before
NSLog(@"Resizing smaller for keyboard");
 
// Get the origin of the keyboard when it finishes animating
NSDictionary *info = [notif userInfo];
NSValue *aValue = [info objectForKey:UIKeyboardFrameEndUserInfoKey];
 
// Get the top of the keyboard in view's coordinate system.
// We need to set the bottom of the scrollview to line up with it
CGRect keyboardRect = [aValue CGRectValue];
  keyboardRect = [self.view convertRect:keyboardRect fromView:nil];
CGFloat keyboardTop = keyboardRect.origin.y;
  
// Resize the scroll view to make room for the keyboard
  CGRect viewFrame = self.view.bounds;
viewFrame.size.height = keyboardTop - self.view.bounds.origin.y;
 
self.scrollView.frame = viewFrame;
keyboardVisible = YES;
}

- (void) keyboardDidHide:(NSNotification *)notif {
NSLog(@"%@", @"Received UIKeyboardDidHideNotification");
 
if (!keyboardVisible) {
NSLog(@"%@", @"Keyboard already hidden. Ignoring notification.");
return;
}
 
// The keyboard was visible
NSLog(@"%@", @"Resizing bigger with no keyboard");
  
// Resize the scroll view back to the full size of our view
self.scrollView.frame = self.view.bounds;
keyboardVisible = NO;
}

- (void)viewDidLoad
{
  scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
//  scroll.contentSize = CGSizeMake(1000, 1000);
  [self.view addSubview:scrollView];
//  UIButton *button = [[UIButton alloc] initWithFrame:CGRectMake(100, 100, 100, 100)];
//  [button setBackgroundColor:[UIColor blackColor]];
//  [scroll addSubview:button];
  UITextView *textView = [[UITextView alloc]initWithFrame:CGRectMake(100, 300, 100, 100)];
  textView.text = @"222";
  textView.font = [UIFont systemFontOfSize:20];
  [scrollView addSubview:textView];
  [super viewDidLoad];
  [textView release];

  self.scrollView.contentSize = self.view.frame.size;
// Do any additional setup after loading the view, typically from a nib.
}

- (void)dealloc
{
  [scrollView release];
  [super dealloc];
}

- (void)didReceiveMemoryWarning
{
  [super didReceiveMemoryWarning];
  // Dispose of any resources that can be recreated.
}

@end

以上是“如何解決IOS中NSNotification鍵盤遮擋問題”這篇文章的所有內(nèi)容,感謝各位的閱讀!相信大家都有了一定的了解,希望分享的內(nèi)容對大家有所幫助,如果還想學習更多知識,歡迎關注創(chuàng)新互聯(lián)網(wǎng)站建設公司行業(yè)資訊頻道!

另外有需要云服務器可以了解下創(chuàng)新互聯(lián)建站aaarwkj.com,海內(nèi)外云服務器15元起步,三天無理由+7*72小時售后在線,公司持有idc許可證,提供“云服務器、裸金屬服務器、高防服務器、香港服務器、美國服務器、虛擬主機、免備案服務器”等云主機租用服務以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡單易用、服務可用性高、性價比高”等特點與優(yōu)勢,專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應用場景需求。

文章題目:如何解決IOS中NSNotification鍵盤遮擋問題-創(chuàng)新互聯(lián)
當前鏈接:http://aaarwkj.com/article14/jsige.html

成都網(wǎng)站建設公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站排名、網(wǎng)站導航、ChatGPT、定制網(wǎng)站網(wǎng)站收錄、網(wǎng)站內(nèi)鏈

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)

搜索引擎優(yōu)化
日韩免费av在线网站| 久久99精品久久久国产| 日本理论高清在线观看| 欧美亚洲少妇人妻系列| 韩国av高清在线观看| 在线播放亚洲一区二区三区| 91香蕉伊人综合久久麻豆| 国内自拍一区二区三区| 国产精品高清另类一区二区三区| 蜜臀午夜精品视频在线观看 | 毛片91成人在线播放| 久久一区二区视频在线观看| 国产龙熟女高潮一区二区| 不卡一区二区三区av电影| 日韩免费av在线观看| 久久最新视频中文字幕| 精品国产av一区二区麻豆| 另类欧美亚洲中文在线综合| 午夜在线观看成人av| 国产成人大片一区二区三区| 欧美亚洲综合另类色妞| 人成午夜视频在线播放| 一区中文字幕人妻少妇| 午夜福利激情视频在线| 中文字幕一区二区精品区| 欧美日韩亚洲一区二区搜索| 国产剧免费看视频网站成人| 国产在线观看一区二区三区精品| 哪里可以看日韩免费毛片| 午夜影院在线观看网站| 一区二区少妇黄色三区| 国产叼嘿一区二区视频| 肥臀大屁股av在线播放| 欧美日韩精品国产精品| 朋友的尤物人妻中文字幕| 夜夜春国产精品不卡一区二区| 白白在线观看网站看看亚洲| 亚洲日本香蕉视频观看视频| 国产一级性生活高清在线| 日韩视频精品一区二区| 2021久久国产综合精品青草|