下面是内存溢出 jb51.cc 通过网络收集整理的代码片段。
内存溢出小编现在分享给大家,也给大家做个参考。
#import "VIEwController.h"@interface VIEwController ()<UITextFIEldDelegate>{ UITextFIEld *_commentTextFIEld;}@end@implementation VIEwController- (voID)vIEwDIDLoad { [super vIEwDIDLoad]; //键盘通知 [[NSNotificationCenter defaultCenter] addobserver:self selector:@selector(keyboarDWasChange:) name:UIKeyboarDWillChangeFrameNotification object:nil]; //实例化输入框 _commentTextFIEld = [[UITextFIEld alloc] initWithFrame:CGRectMake(0,[UIScreen mainScreen].bounds.size.height-35,[UIScreen mainScreen].bounds.size.wIDth,32)]; [[NSNotificationCenter defaultCenter]addobserver:self selector:@selector (textFIEldChange:) name:UITextFIEldTextDIDChangeNotification object:_commentTextFIEld]; _commentTextFIEld.borderStyle = UITextborderStyleRoundedRect; _commentTextFIEld.returnKeyType = UIReturnKeyDone; _commentTextFIEld.enablesReturnKeyautomatically = YES; _commentTextFIEld.placeholder = @"请输入 王木木 点击完成"; _commentTextFIEld.backgroundcolor = [UIcolor whitecolor]; _commentTextFIEld.delegate = self; [self.vIEw addSubvIEw:_commentTextFIEld]; self.vIEw.backgroundcolor = [UIcolor bluecolor];}- (voID)btn{ NSLog(@"dsfa");}#pragma mark - 键盘 改变通知 d键盘-(voID)keyboarDWasChange:(NSNotification *)notification{ NSDictionary *info = [notification userInfo]; if ([[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y != [UIScreen mainScreen].bounds.size.height) { _commentTextFIEld.frame = CGRectMake(0,[[info objectForKey:UIKeyboardFrameEndUserInfoKey] CGRectValue].origin.y-45,45); }else { _commentTextFIEld.frame = CGRectMake(0,[UIScreen mainScreen].bounds.size.height - 45,45); }}//点击界面vIEw 触发 收键盘- (voID)@R_502_5033@Began:(NSSet *)@R_502_5033@ withEvent:(UIEvent *)event{ [_commentTextFIEld resignFirstResponder]; _commentTextFIEld.frame = CGRectMake(0,45);}-(voID)textFIEldChange:(NSNotification *)notification{ UITextFIEld *textFIEld=[notification object]; Nsstring *lang = [textFIEld.textinputMode primaryLanguage]; // 键盘输入模式 if ([lang isEqualToString:@"zh-Hans"]) { // 简体中文输入,包括简体拼音,健体五笔,简体手写 UITextRange *selectedRange = [textFIEld markedTextRange]; //获取高亮部分 UITextposition *position = [textFIEld positionFromposition:selectedRange.start offset:0]; // 没有高亮选择的字,则对已输入的文字进行字数统计和限制 if (!position) { if ([textFIEld.text isEqualToString:@"王木木"]) { UIAlertVIEw *ale = [[UIAlertVIEw alloc]initWithTitle:@"我爱你" message:nil delegate:nil cancelbuttonTitle:@"谢谢" otherbuttonTitles: nil]; [ale show]; } } } }- (voID)dIDReceiveMemoryWarning { [super dIDReceiveMemoryWarning]; // dispose of any resources that can be recreated.}@end
以上是内存溢出(jb51.cc)为你收集整理的全部代码内容,希望文章能够帮你解决所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
总结以上是内存溢出为你收集整理的iOS实现聊天输入框全部内容,希望文章能够帮你解决iOS实现聊天输入框所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)