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

推荐订阅源

Martin Fowler
Martin Fowler
Microsoft Security Blog
Microsoft Security Blog
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
Vercel News
Vercel News
Y
Y Combinator Blog
D
DataBreaches.Net
IT之家
IT之家
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
博客园_首页
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
H
Hackread – Cybersecurity News, Data Breaches, AI and More
WordPress大学
WordPress大学
H
Help Net Security
GbyAI
GbyAI
C
Check Point Blog
L
LangChain Blog
小众软件
小众软件
T
The Blog of Author Tim Ferriss
MyScale Blog
MyScale Blog
G
Google Developers Blog
月光博客
月光博客
V
V2EX
M
MIT News - Artificial intelligence
博客园 - 叶小钗

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

微信小程序-本地云函数调试失败,卡在“正在开启本地调试中” 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];