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

如何解決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)化
亚洲国产欧美精品综合在线| 天天天干夜夜添狠操美女| 国产亚洲日本精品二区| 日本一区二区三区高清在线| 欧美亚洲国产另类第一页| 亚洲日本va午夜中文字幕一区| 国产一区二区三区日本精品| 精品国产综合一区二区三区| 日本在线一区二区三区| 日韩精品a区二区在线电影| 亚洲综合av一区二区三区四区| 黑人巨大精品欧美久久| 亚洲成av人一区二区三区| 99热这里只有精品免费播放| 中文人妻熟妇乱又伦精品| 一区二区三区免费视频少妇| 日韩成人高清免费在线| 日本99精品视频10| 懂色av中文一区二区| 日本高清视频免费一区| 久久不卡高清免费av| 国产精品亚洲综合制服日韩| 日本黄色录像黄色录像| 国产高清不卡av在线| 亚洲国产日韩精品欧美| 亚洲欧美av中文日韩二区| 色香蕉精品国产综合| 91麻豆精品国产综合久久久| 成人免费视频国产免费| 一区二区三区蜜桃av| 日本福利影院在线观看| 国产精品一区二区精品| 粉嫩欧美一区二区三区| 偷拍色图一区二区二区| 亚洲综合一区二区在线视频| 国产乱码免费一区二区三区| 欧美成人极品一区二区三区| 片子免费毛片日韩不卡一区| 精品人妻一区二区三区蜜桃电| 国产精品久久一国产精品| 女同av免费观看网站|