惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - 三生石上(FineUI控件)
WordPress大学
WordPress大学
S
SegmentFault 最新的问题
小众软件
小众软件
T
Tailwind CSS Blog
博客园 - 聂微东
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
V
Visual Studio Blog
罗磊的独立博客
有赞技术团队
有赞技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
Jina AI
Jina AI
量子位
云风的 BLOG
云风的 BLOG
Recent Announcements
Recent Announcements
Hugging Face - Blog
Hugging Face - Blog
P
Proofpoint News Feed
N
Netflix TechBlog - Medium
GbyAI
GbyAI
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
腾讯CDC
美团技术团队

博客园 - 狗尾草-大数据收割基

微信小程序-本地云函数调试失败,卡在“正在开启本地调试中” VS Code调试Python时,选择conda虚拟环境,配置环境变量 微信小程序集成vant mac配置ssh 到github (ios)MPMoviePlayerController首次播放视频的时候,没有控制条 ios app响应background,foreground 事件实现 ios UIScrollView 中控件自动增加间隔 iOS 导航栏实现总结 ios界面布局整理 android ProGuard 代码混淆实现 mac版 android破解软件下载安装 在unix系统下的 .o文件 .a文件 .so文件说明和相互关系 android中的广播接收实现总结 用java的jdk 生成android 的jni接口文档 Android 自定义Application android项目中配置NDK自动编译生成so文件 创建android Notification (ios) 屏幕触摸总结 sqlite数据库 select 查询带换行符数据
(ios) nsnotification总结
狗尾草-大数据收割基 · 2014-01-20 · via 博客园 - 狗尾草-大数据收割基

1  文本输入,键盘显示时,view向上,键盘隐藏时,view向下

1.1 注册键盘显示,关闭通知,并实现主界面上下变动

 [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil];
    
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyboardWillHide:) name:UIKeyboardWillHideNotification object:nil];
}


-(void)keyboardWillShow:(NSNotification *)aNotification
{

    CGRect keyBoardRect=[[[aNotification userInfo]objectForKey:UIKeyboardFrameBeginUserInfoKey]CGRectValue];
    
    NSTimeInterval animalInterval=[[[aNotification userInfo]objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    CGRect frame=self.view.frame;
    frame.origin.y=-keyBoardRect.size.height;
    [UIView beginAnimations:@"keyboardshow" context:nil];
    [UIView setAnimationDuration:animalInterval];
    self.view.frame=frame;
    [UIView commitAnimations];


}

-(void)keyboardWillHide:(NSNotification *)aNotification
{

    NSTimeInterval animalInterval=[[[aNotification userInfo]objectForKey:UIKeyboardAnimationDurationUserInfoKey] doubleValue];
    CGRect frame=self.view.frame;
    frame.origin.y=0;
    [UIView beginAnimations:@"keyboardhide" context:nil];
    [UIView setAnimationDuration:animalInterval];
    self.view.frame=frame;
    [UIView commitAnimations];
    
}

1.2 文本框初始化,并实现UITextViewDelegate委托

    self.textbox.returnKeyType=UIReturnKeyDone;
    self.textbox.delegate=self;
}

 - (BOOL)textFieldShouldReturn:(UITextView *)textView
{
 [textView resignFirstResponder];
    return YES;
}

2 自定义notification

 2.1 定义侦听自定义notification观察者

//注册观察者,侦听自定义通知
    [[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(selfNotificationDO:) name:@"CustomNotification" object:nil];

}

-(void)selfNotificationDO:(NSNotification *)aNotification
{
     //处理notification
    //........
}

2.2 生成一个自定义notification

//生成一个自定义Notification
    [[NSNotificationCenter defaultCenter] postNotificationName:@"CustomNotification" object:self];