- 浏览: 2543482 次
- 性别:
- 来自: 苏州
文章分类
最新评论
-
jsntghf:
peio 写道这个怎么运行?Ruby On Rails的环境搭 ...
多文件上传之uploadify -
peio:
这个怎么运行?
多文件上传之uploadify -
往事如烟1:
我的项目是自己init了一个原始的project,之后将ver ...
React Native热部署之CodePush -
jsntghf:
往事如烟1 写道我按照你的说明进行,发现app退出之后,在进入 ...
React Native热部署之CodePush -
往事如烟1:
我按照你的说明进行,发现app退出之后,在进入不正确,请问是什 ...
React Native热部署之CodePush
HPTextViewInternal.h
#import <UIKit/UIKit.h> @interface HPTextViewInternal : UITextView { } @end
HPTextViewInternal.m
#import "HPTextViewInternal.h" @implementation HPTextViewInternal - (void) setContentOffset:(CGPoint)s { if(self.tracking || self.decelerating) { self.contentInset = UIEdgeInsetsMake(0, 0, 0, 0); } else { float bottomOffset = (self.contentSize.height - self.frame.size.height + self.contentInset.bottom); if(s.y < bottomOffset && self.scrollEnabled) { self.contentInset = UIEdgeInsetsMake(0, 0, 8, 0); } } [super setContentOffset:s]; } - (void) setContentInset:(UIEdgeInsets)s { UIEdgeInsets insets = s; if(s.bottom > 8) insets.bottom = 0; insets.top = 0; [super setContentInset:insets]; } @end
HPGrowingTextView.h
#import <UIKit/UIKit.h> @class HPGrowingTextView; @class HPTextViewInternal; @protocol HPGrowingTextViewDelegate @optional - (BOOL) growingTextViewShouldBeginEditing:(HPGrowingTextView *)growingTextView; - (BOOL) growingTextViewShouldEndEditing:(HPGrowingTextView *)growingTextView; - (void) growingTextViewDidBeginEditing:(HPGrowingTextView *)growingTextView; - (void) growingTextViewDidEndEditing:(HPGrowingTextView *)growingTextView; - (BOOL) growingTextView:(HPGrowingTextView *)growingTextView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)text; - (void) growingTextViewDidChange:(HPGrowingTextView *)growingTextView; - (void) growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height; - (void) growingTextView:(HPGrowingTextView *)growingTextView didChangeHeight:(float)height; - (void) growingTextViewDidChangeSelection:(HPGrowingTextView *)growingTextView; - (BOOL) growingTextViewShouldReturn:(HPGrowingTextView *)growingTextView; @end @interface HPGrowingTextView : UIView <UITextViewDelegate> { HPTextViewInternal *internalTextView; int minHeight; int maxHeight; int maxNumberOfLines; int minNumberOfLines; BOOL animateHeightChange; NSObject <HPGrowingTextViewDelegate> *delegate; NSString *text; UIFont *font; UIColor *textColor; UIColor *backgroundColor; UITextAlignment textAlignment; NSRange selectedRange; BOOL editable; UIDataDetectorTypes dataDetectorTypes; UIReturnKeyType returnKeyType; } @property int maxNumberOfLines; @property int minNumberOfLines; @property BOOL animateHeightChange; @property (retain) UITextView *internalTextView; @property (assign) NSObject<HPGrowingTextViewDelegate> *delegate; @property (nonatomic, assign) NSString *text; @property (nonatomic, assign) UIFont *font; @property (nonatomic, assign) UIColor *textColor; @property (nonatomic, assign) UIColor *backgroundColor; @property (nonatomic) UITextAlignment textAlignment; @property (nonatomic) NSRange selectedRange; @property (nonatomic, getter = isEditable) BOOL editable; @property (nonatomic) UIDataDetectorTypes dataDetectorTypes __OSX_AVAILABLE_STARTING(__MAC_NA, __IPHONE_3_0); @property (nonatomic) UIReturnKeyType returnKeyType; - (BOOL) hasText; - (void) scrollRangeToVisible:(NSRange)range; @end
HPGrowingTextView.m
#import "HPGrowingTextView.h" #import "HPTextViewInternal.h" @implementation HPGrowingTextView @synthesize internalTextView; @synthesize maxNumberOfLines; @synthesize minNumberOfLines; @synthesize delegate; @synthesize text; @synthesize font; @synthesize textColor; @synthesize backgroundColor; @synthesize textAlignment; @synthesize selectedRange; @synthesize editable; @synthesize dataDetectorTypes; @synthesize animateHeightChange; @synthesize returnKeyType; - (id) initWithFrame:(CGRect)frame { if ((self = [super initWithFrame:frame])) { CGRect r = frame; r.origin.y = 0; r.origin.x = 0; internalTextView = [[HPTextViewInternal alloc] initWithFrame:r]; internalTextView.delegate = self; internalTextView.scrollEnabled = NO; internalTextView.font = [UIFont fontWithName:@"Helvetica" size:13]; internalTextView.contentInset = UIEdgeInsetsZero; internalTextView.showsHorizontalScrollIndicator = NO; internalTextView.text = @"-"; [self addSubview:internalTextView]; UIView *internal = (UIView*)[[internalTextView subviews] objectAtIndex:0]; minHeight = internal.frame.size.height; minNumberOfLines = 1; animateHeightChange = YES; internalTextView.text = @""; [self setMaxNumberOfLines:3]; } return self; } - (void) sizeToFit { CGRect r = self.frame; r.size.height = minHeight; self.frame = r; } - (void) setFrame:(CGRect)aframe { CGRect r = aframe; r.origin.y = 0; r.origin.x = 0; internalTextView.frame = r; [super setFrame:aframe]; } - (void) setMaxNumberOfLines:(int)n { UITextView *test = [[HPTextViewInternal alloc] init]; test.font = internalTextView.font; test.hidden = YES; NSMutableString *newLines = [NSMutableString string]; if(n == 1) { [newLines appendString:@"-"]; } else { for(int i = 1; i < n; i++) { [newLines appendString:@"\n"]; } } test.text = newLines; [self addSubview:test]; maxHeight = test.contentSize.height; maxNumberOfLines = n; [test removeFromSuperview]; [test release]; } - (void) setMinNumberOfLines:(int)m { UITextView *test = [[HPTextViewInternal alloc] init]; test.font = internalTextView.font; test.hidden = YES; NSMutableString *newLines = [NSMutableString string]; if(m == 1) { [newLines appendString:@"-"]; } else { for(int i = 1; i < m; i++){ [newLines appendString:@"\n"]; } } test.text = newLines; [self addSubview:test]; minHeight = test.contentSize.height; [self sizeToFit]; minNumberOfLines = m; [test removeFromSuperview]; [test release]; } - (void) textViewDidChange:(UITextView *)textView { NSInteger newSizeH = internalTextView.contentSize.height; if(newSizeH < minHeight || !internalTextView.hasText) newSizeH = minHeight; if (internalTextView.frame.size.height != newSizeH) { if (newSizeH <= maxHeight) { if(animateHeightChange){ [UIView beginAnimations:@"" context:nil]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(growDidStop)]; [UIView setAnimationBeginsFromCurrentState:YES]; } if ([delegate respondsToSelector:@selector(growingTextView:willChangeHeight:)]) { [delegate growingTextView:self willChangeHeight:newSizeH]; } CGRect internalTextViewFrame = self.frame; internalTextViewFrame.size.height = newSizeH; self.frame = internalTextViewFrame; internalTextViewFrame.origin.y = 0; internalTextViewFrame.origin.x = 0; internalTextView.frame = internalTextViewFrame; if(animateHeightChange){ [UIView commitAnimations]; } } if (newSizeH >= maxHeight) { if(!internalTextView.scrollEnabled) { internalTextView.scrollEnabled = YES; [internalTextView flashScrollIndicators]; } } else { internalTextView.scrollEnabled = NO; } } if ([delegate respondsToSelector:@selector(growingTextViewDidChange:)]) { [delegate growingTextViewDidChange:self]; } } - (void) growDidStop { if ([delegate respondsToSelector:@selector(growingTextView:didChangeHeight:)]) { [delegate growingTextView:self didChangeHeight:self.frame.size.height]; } } - (BOOL) resignFirstResponder { [super resignFirstResponder]; return [internalTextView resignFirstResponder]; } - (void) dealloc { [internalTextView release]; [super dealloc]; } #pragma mark UITextView properties - (void) setText:(NSString *)atext { internalTextView.text= atext; } - (NSString *)text { return internalTextView.text; } - (void)setFont:(UIFont *)afont { internalTextView.font = afont; [self setMaxNumberOfLines:maxNumberOfLines]; [self setMinNumberOfLines:minNumberOfLines]; } - (UIFont *)font { return internalTextView.font; } - (void) setTextColor:(UIColor *)color { internalTextView.textColor = color; } - (UIColor *)textColor { return internalTextView.textColor; } - (void) setBackgroundColor:(UIColor *)color { internalTextView.backgroundColor = color; } - (UIColor *) backgroundColor { return internalTextView.backgroundColor; } - (void) setTextAlignment:(UITextAlignment)aligment { internalTextView.textAlignment = aligment; } - (UITextAlignment) textAlignment { return internalTextView.textAlignment; } - (void) setSelectedRange:(NSRange)range { internalTextView.selectedRange = range; } - (NSRange)selectedRange { return internalTextView.selectedRange; } - (void) setEditable:(BOOL)beditable { internalTextView.editable = beditable; } - (BOOL) isEditable { return internalTextView.editable; } - (void) setReturnKeyType:(UIReturnKeyType)keyType { internalTextView.returnKeyType = keyType; } - (UIReturnKeyType) returnKeyType { return internalTextView.returnKeyType; } - (void) setDataDetectorTypes:(UIDataDetectorTypes)datadetector { internalTextView.dataDetectorTypes = datadetector; } - (UIDataDetectorTypes) dataDetectorTypes { return internalTextView.dataDetectorTypes; } - (BOOL) hasText { return [internalTextView hasText]; } - (void) scrollRangeToVisible:(NSRange)range { [internalTextView scrollRangeToVisible:range]; } #pragma mark - #pragma mark UITextViewDelegate - (BOOL) textViewShouldBeginEditing:(UITextView *)textView { if ([delegate respondsToSelector:@selector(growingTextViewShouldBeginEditing:)]) { return [delegate growingTextViewShouldBeginEditing:self]; } else { return YES; } } - (BOOL) textViewShouldEndEditing:(UITextView *)textView { if ([delegate respondsToSelector:@selector(growingTextViewShouldEndEditing:)]) { return [delegate growingTextViewShouldEndEditing:self]; } else { return YES; } } - (void)textViewDidBeginEditing:(UITextView *)textView { if ([delegate respondsToSelector:@selector(growingTextViewDidBeginEditing:)]) { [delegate growingTextViewDidBeginEditing:self]; } } - (void) textViewDidEndEditing:(UITextView *)textView { if ([delegate respondsToSelector:@selector(growingTextViewDidEndEditing:)]) { [delegate growingTextViewDidEndEditing:self]; } } - (BOOL) textView:(UITextView *)textView shouldChangeTextInRange:(NSRange)range replacementText:(NSString *)atext { if(![textView hasText] && [atext isEqualToString:@""]) return NO; if ([atext isEqualToString:@"\n"]) { if ([delegate respondsToSelector:@selector(growingTextViewShouldReturn:)]) { if (![delegate performSelector:@selector(growingTextViewShouldReturn:) withObject:self]) { return YES; } else { [textView resignFirstResponder]; return NO; } } } return YES; } - (void) textViewDidChangeSelection:(UITextView *)textView { if ([delegate respondsToSelector:@selector(growingTextViewDidChangeSelection:)]) { [delegate growingTextViewDidChangeSelection:self]; } } @end
AddMessageViewController.h
#import <UIKit/UIKit.h> #import "HPGrowingTextView.h" @class ReceptionListViewController; @interface AddMessageViewController : UIViewController<UITextFieldDelegate, UIScrollViewDelegate, HPGrowingTextViewDelegate> { UIView *_sendView; UIScrollView *_receptionView; UITextField *_receptionLabel; NSMutableArray *_receptionArray; NSMutableArray *_receptionDtoArray; HPGrowingTextView *_sendTextView; UITextField *_sendTextField; ReceptionListViewController *_receptionListViewController; UINavigationController *_receptionNavigationController; UIButton *_addButton; CGFloat _receptionWidth; CGFloat _receptionHeight; BOOL _isButtonDelete; BOOL _isToReceptionList; } @property (nonatomic, retain) IBOutlet UIView *sendView; @property (nonatomic, retain) IBOutlet UIScrollView *receptionView; @property (nonatomic, retain) HPGrowingTextView *sendTextView; @property (nonatomic, retain) IBOutlet UITextField *receptionLabel; @property (nonatomic, retain) NSMutableArray *receptionArray; @property (nonatomic, retain) NSMutableArray *receptionDtoArray; @property (nonatomic, retain) IBOutlet UITextField *sendTextField; @property (nonatomic, retain) IBOutlet ReceptionListViewController *receptionListViewController; @property (nonatomic, retain) IBOutlet UINavigationController *receptionNavigationController; @property (nonatomic, retain) IBOutlet UIButton *addButton; @property (nonatomic, assign) CGFloat receptionWidth; @property (nonatomic, assign) CGFloat receptionHeight; @property (nonatomic, assign) BOOL isButtonDelete; @property (nonatomic, assign) BOOL isToReceptionList; - (IBAction) dismissMyselfAction:(id)sender; - (IBAction) addReceptionAction:(id)sender; - (IBAction) sendMessageAction:(id)sender; - (void) initForPage; - (void) addReceiver; - (void) resumeView; - (IBAction) deleteButton:(id)sender; @end
AddMessageViewController.m
#import "AddMessageViewController.h" #import "ReceptionListViewController.h" @implementation AddMessageViewController @synthesize sendView = _sendView,receptionView = _receptionView; @synthesize receptionLabel = _receptionLabel, receptionArray = _receptionArray; @synthesize receptionListViewController = _receptionListViewController; @synthesize receptionNavigationController = _receptionNavigationController; @synthesize addButton = _addButton; @synthesize receptionWidth = _receptionWidth, receptionHeight = _receptionHeight; @synthesize isButtonDelete = _isButtonDelete; @synthesize sendTextField = _sendTextField; @synthesize isToReceptionList = _isToReceptionList; @synthesize receptionDtoArray = _receptionDtoArray; @synthesize sendTextView = _sendTextView; - (void) viewDidLoad { [super viewDidLoad]; self.receptionWidth = 62; self.receptionHeight = 6; self.sendTextView = [[HPGrowingTextView alloc] initWithFrame:CGRectMake(68, 205, 185, 35)]; self.sendTextView.minNumberOfLines = 1; self.sendTextView.maxNumberOfLines = 6; self.sendTextView.font = [UIFont systemFontOfSize:15.0f]; self.sendTextView.delegate = self; self.sendTextView.backgroundColor = [UIColor clearColor]; [self.view addSubview:self.sendTextView]; [self.sendTextView sizeToFit]; self.sendTextField.frame = CGRectMake(66, 5, 190, 36); NSMutableArray *array = [[NSMutableArray alloc] init]; self.receptionDtoArray = array; [array release]; self.view.backgroundColor = [UIColor colorWithRed:0.859f green:0.886f blue:0.929f alpha:1.0f]; self.receptionListViewController.addMessageViewController = self; } - (void) viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self initForPage]; } - (void) viewWillDisappear:(BOOL)animated { [super viewWillDisappear:animated]; if (!self.isToReceptionList) { NSMutableArray *array = [[NSMutableArray alloc] init]; self.receptionDtoArray = array; [array release]; [self resumeView]; self.sendTextView.text = @""; self.sendView.frame = CGRectMake(0, 200, 320, 44); self.sendTextField.frame = CGRectMake(66, 5, 190, 36); self.sendTextView.frame = CGRectMake(68, 205, 185, 35); } } - (void)dealloc { [_sendView release]; [_receptionView release]; [_receptionLabel release]; [_receptionArray release]; [_receptionListViewController release]; [_receptionNavigationController release]; [_addButton release]; [_sendTextField release]; [_receptionDtoArray release]; [_sendTextView release]; [super dealloc]; } - (void) initForPage { [self.sendTextField becomeFirstResponder]; [self.receptionLabel becomeFirstResponder]; } - (void) addReceiver { [self resumeView]; NSMutableString *receiver = [[NSMutableString alloc] init]; NSMutableArray *tempArray = [[NSMutableArray alloc] init]; self.receptionArray = tempArray; [tempArray release]; for (int i = 0; i < self.receptionDtoArray.count; i++) { NSString *guideName = [self.receptionDtoArray objectAtIndex:i]; [self.receptionArray addObject:guideName]; UIFont *baseFone = [UIFont systemFontOfSize:12]; CGSize size = [guideName sizeWithFont:baseFone constrainedToSize:CGSizeMake(200, 1000) lineBreakMode:UILineBreakModeWordWrap]; UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; [button setTitle:guideName forState:UIControlStateNormal]; UIImage *normalImage = [UIImage imageNamed:@"act-normal.png"]; [button setBackgroundImage:[normalImage stretchableImageWithLeftCapWidth:21 topCapHeight:14] forState:UIControlStateNormal]; [button setBackgroundImage:[normalImage stretchableImageWithLeftCapWidth:21 topCapHeight:14] forState:UIControlStateHighlighted]; UIImage *highImage = [UIImage imageNamed:@"act.png"]; [button setBackgroundImage:[highImage stretchableImageWithLeftCapWidth:21 topCapHeight:14]forState:UIControlStateDisabled]; [button setTitleColor:[UIColor blackColor] forState:UIControlStateNormal]; [button setTitleColor:[UIColor whiteColor] forState:UIControlStateDisabled]; button.titleLabel.font = [UIFont systemFontOfSize:12]; button.tag = i; [button addTarget:self action:@selector(deleteButton:) forControlEvents:UIControlEventTouchUpInside]; //设置按钮位置 if (self.receptionWidth + size.width + 10 >= 275) { self.receptionHeight = self.receptionHeight + size.height + 12; self.receptionWidth = 8; if (self.receptionHeight > 6.0f) { button.frame = CGRectMake(self.receptionWidth, self.receptionHeight, size.width + 18, 26); } else { button.frame = CGRectMake(self.receptionWidth - 52, self.receptionHeight, size.width + 18, 26); } } else { button.frame = CGRectMake(self.receptionWidth, self.receptionHeight, size.width + 18, 26); } [self.receptionView addSubview:button]; self.receptionWidth += size.width + 23; //设置隐藏的textfield中的值 if (i == self.receptionDtoArray.count - 1) { [receiver appendFormat:@"%@", guideName]; } else { [receiver appendFormat:@"%@,", guideName]; } } self.receptionLabel.text = receiver; self.addButton.frame = CGRectMake(280, self.receptionHeight, 29, 29); self.addButton.tag = 99; [self.receptionView addSubview:self.addButton]; //定义scrollview高度 self.receptionView.frame = CGRectMake(0, 44, 320, self.receptionHeight + 32); if (self.receptionView.frame.size.height >= 199 - self.sendView.frame.size.height) { self.receptionView.frame = CGRectMake(0, 44, 320, 199 - self.sendView.frame.size.height); } self.receptionView.contentSize = CGSizeMake(320, self.receptionHeight + 40); } //页面恢复原状,按钮全部去掉 - (void) resumeView { self.receptionView.frame = CGRectMake(0, 44, 320, 38); self.receptionView.contentSize = CGSizeMake(320, 38); self.receptionWidth = 62; self.receptionHeight = 6; for(UIView *subview in [self.receptionView subviews]) { if([[subview class] isSubclassOfClass:UIButton.class]){ UIButton *tipsButton = (UIButton *)subview; [tipsButton removeFromSuperview]; } } } - (IBAction) deleteButton:(id)sender { self.isButtonDelete = YES; NSMutableArray *tempArray = [[NSMutableArray alloc] init]; self.receptionArray = tempArray; [tempArray release]; for (int i = 0; i < self.receptionDtoArray.count; i++) { NSString *guideName = [self.receptionDtoArray objectAtIndex:i]; [self.receptionArray addObject:guideName]; } UIButton *button = (UIButton *)sender; //当选中当前按钮时,其他按钮恢复原状,可以点击 for(UIView *subview in [self.receptionView subviews]){ if([[subview class] isSubclassOfClass:UIButton.class]){ UIButton *tipsButton = (UIButton *)subview; if (tipsButton.tag != 99) { [tipsButton setEnabled:YES]; } } } //当前按钮进入选中状态而且不可点击 [button setEnabled:NO]; //删除替补数组中的信息 for (int i = 0; i < self.receptionArray.count; i++) { if (button.tag == i) { [self.receptionArray removeObject:[self.receptionArray objectAtIndex:i]]; } } } #pragma mark - #pragma mark TextField Delegate Method - (BOOL) textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string { NSString *candidateString = [textField.text stringByReplacingCharactersInRange:range withString:string]; if ([candidateString length] < [self.receptionLabel.text length]) { //如果是选中状态则删除对应按钮,不然就将最后一个联系人设为选中状态 if (self.isButtonDelete) { for (int i = 0; i < self.receptionDtoArray.count; i++) { NSString *guideName = [self.receptionDtoArray objectAtIndex:i]; if ([self.receptionArray containsObject:guideName]) { } else { [self.receptionDtoArray removeObject:guideName]; } } [self addReceiver]; self.isButtonDelete = NO; } else { //将scrollview子视图里面联系人的按钮存放在新的数组里 NSMutableArray *tempArray = [[NSMutableArray alloc] init]; for(UIView *subview in [self.receptionView subviews]){ if([[subview class] isSubclassOfClass:UIButton.class]){ UIButton *tipsButton = (UIButton *)subview; if(tipsButton.tag != 99){ [tempArray addObject:tipsButton]; } } } if ([[self.receptionView subviews] count] != 1) { for(UIButton *button in tempArray){ if (button == [tempArray lastObject]) { [self deleteButton:button]; } } } } } return NO; } - (void) growingTextView:(HPGrowingTextView *)growingTextView willChangeHeight:(float)height { float diff = (self.sendTextView.frame.size.height - height); CGRect r = self.sendTextView.frame; r.origin.y += diff; self.sendTextView.frame = r; CGRect sendFrame = self.sendView.frame; sendFrame.origin.y += diff; sendFrame.size.height -= diff; self.sendView.frame = sendFrame; CGRect textFieldFrame = self.sendTextField.frame; textFieldFrame.size.height -= diff; self.sendTextField.frame = textFieldFrame; } - (BOOL) growingTextViewShouldBeginEditing:(HPGrowingTextView *)growingTextView { [self.receptionLabel setHidden:NO]; [self resumeView]; return YES; } - (BOOL) textFieldShouldBeginEditing:(UITextField *)textField { //切换textfield的状态 if (textField == self.receptionLabel) { [self.receptionLabel setHidden:YES]; [self addReceiver]; } return YES; } - (IBAction) dismissMyselfAction:(id)sender { self.isToReceptionList = NO; [self dismissModalViewControllerAnimated:YES]; } - (IBAction) addReceptionAction:(id)sender { self.isToReceptionList = YES; [self presentModalViewController:self.receptionNavigationController animated:YES]; } @end
示例图:
- NoteTestDemo.zip (986.5 KB)
- 下载次数: 94
发表评论
-
Error watching file for changes: EMFILE
2016-12-15 11:57 1309执行npm start后报错: Error watc ... -
CocoaPods升级1.1.1报错
2016-12-15 08:39 799ERROR: While executing gem .. ... -
Visual Studio Code运行React Native报错
2016-06-13 09:43 1622React Native:0.27.2 React:15 ... -
React Native 0.27.2编译报错this._nativeModule.addListener is not a function
2016-06-12 15:21 3866React Native:0.27.2 React:15 ... -
Unable to resolve module ReactDefaultPerf from
2016-06-02 13:04 2791package.json信息如下: "reac ... -
React Native 0.26.2编译报错Undefined symbols for architecture x86_64
2016-05-26 11:15 2030React Native:0.26.2 React:15. ... -
Failed to update auto layout status: Failed to load designables from path (null)
2016-04-05 22:11 1722确保CocoaPods是0.36.1以上版本,然后在podf ... -
集成微信支付出现Undefined symbols for architecture x86_64错误
2016-03-21 13:22 1755Undefined symbols for architec ... -
React Native热部署之CodePush
2016-01-10 22:27 6255本文使用的环境是Mac OS 10.11.1、Xcode ... -
浅谈React Native中的FlexBox布局
2015-11-17 18:38 4310React Native通过一个基于FlexBox的布局引 ... -
React Native之构建一个简单的列表页
2015-10-23 14:45 2169本文中我们将创建一个简单的电影应用,这个应用将从Rotten ... -
React Native之环境搭建
2015-10-20 16:30 1451本文使用的环境是Mac O ... -
获取图片属性的方法
2015-10-18 20:43 3149很多时候我们需要获 ... -
NSCache的下标用法
2015-09-18 00:19 1219NSCache类和NSDictionary类很相似,也提供 ... -
如何给category添加属性
2015-08-16 10:41 695主要是使用了runtime中的associative机制。 ... -
UITableView的两种重用Cell方法的区别
2015-08-10 13:07 16160UITableView中有两种重用Cell的方法: - ... -
SDImageCache.m报错Unused variable 'fileName'
2015-08-04 21:56 1179GCC手册中的相关解释: unused:This att ... -
Swift调用Objective-C
2015-07-13 23:33 1232Swift调用Objective-C需要一个名为<工程 ... -
使用GCD实现倒计时
2015-07-24 21:47 1090__block int timeout = 60; // ... -
导航栏加分割线的实现
2015-07-01 22:00 1772self.view.backgroundColor = [U ...
相关推荐
这就是“ios-tableviewcell 输入内容实时刷新高度 自适应”这一主题的核心内容。 首先,我们需要理解UITableViewCell的工作原理。每个cell都有一个固定的height(高度),默认情况下,这个高度是固定的,不会随内容...
在许多场景下,我们希望`UITextView`的高度能够根据其内部的文本内容自动调整,以便适应不同长度的文本,这就是所谓的"textview自适应高度"。这个特性使得用户界面更加灵活,可以更好地适应用户的输入。以下将详细...
输入框高度自适应是一项技术,它允许输入框根据用户输入的内容动态调整其高度,以保持良好的用户体验。本资源"ios-输入框高度自适应.zip"提供了一个简单的实现方案,帮助开发者实现这一功能,并为进一步扩展提供了...
标题“iOS_输入栏自适应键盘的高度”揭示了一个关键的UI优化问题:如何确保输入栏在键盘出现时能够自动调整其位置,以便用户可以舒适地看到和编辑文本。 在iOS中,键盘的高度并非固定不变,它会根据设备的屏幕尺寸...
本项目“ios-TableViewCell动态输入 自适应高度 UITextView DynamicHeight.zip”正解决了这个问题,尤其适用于iOS 8.0及更高版本。 首先,我们要理解的是UITableViewCell的动态高度计算。在iOS 8.0之后,苹果引入了...
`TextViewHighlyAdapted` 项目就是针对这个需求提供的一种解决方案,它专门处理`UITextView`在Objective-C中的高度自适应问题。 `UITextView` 的默认行为是有一个固定的大小,当用户输入的文本超过视图的高度时,...
本话题主要关注`UILabel`和`UITextView`这两个UI组件的高度自适应。 `UILabel`是iOS中用于显示单行或多行文本的控件。默认情况下,`UILabel`只会显示一行文本,但通过设置`numberOfLines`属性为0,可以让它显示多行...
"ios-高度自适应的TextView.zip"这个资源包提供了一个名为ZWTextView的解决方案,专门用于实现这种高度自适应的功能。 ZWTextView是基于苹果的UITextView进行的自定义扩展,它通过监听用户的输入行为,实时计算文本...
在iOS应用开发中,用户界面的设计与交互是至关重要的,特别是在需要用户输入信息的地方。...而通过使用像`GrowTextView-master`这样的开源项目,开发者可以更快地在项目中实现高度自适应的文本输入框功能。
在iOS开发中,自适应`UITextView`和创建画渐变圆形是常见的视觉效果实现,它们涉及到Apple的Core Graphics框架,特别是`UIBezierPath`、`CAShapeLayer`、`CAGradientLayer`以及`CABasicAnimation`。这些技术在创建...
为TextView设置placeholder并且高度随文本多少进行自适应.zip”中,包含了一个名为`CustomTextView`的自定义`TextView`类,它扩展了`UITextView`,并实现了`placeholder`功能以及文本数量变化时的高度自适应。...
本文将深入探讨如何使用Swift创建这样一个自适应高度的TextView,并确保其使用简单、效果流畅。 首先,我们需要理解TextView的基本概念。TextView是iOS应用中用于显示和编辑多行文本的视图,通常用于长文本输入场景...
总的来说,FMGrowingTextView 是一个实用的 iOS 开源组件,通过结合使用 FMConstraintSwitch,开发者可以轻松地处理 UITextView 高度自适应的问题,提高应用的交互性和用户体验。在实际项目中,合理利用这类工具,...
当接收到键盘将要显示的通知时,我们可以获取到键盘的高度和动画持续时间,然后相应地调整`UITextView`的位置;当键盘将要隐藏时,恢复`UITextView`的原始位置。 实现自适应`UITextView`的关键步骤如下: 1. 注册...
本文将深入探讨iOS 8及更高版本中实现Cell高度自适应的“黑魔法”,特别是如何利用UITableView和UICollectionView的新特性优化性能。 首先,我们要理解在iOS 8之前,自定义Cell高度的方法。在没有使用Auto Layout的...
IOS 中UITextField,UITextView,UILabel 根据内容来计算高度 在开发的过程中,常常遇到根据内容来决定控件的高度的情况,常见的就是UITextField,UITextView,UILabel这三个控件,下面一UITextView 为例来说明一下: ...
接下来,我们关注TextView的高度自适应。在TextView的`textDidChange`代理方法中,我们可以实时获取到TextView的contentSize,然后更新Cell的高度。代码示例如下: ```swift func textViewDidChange(_ textView: ...
描述中进一步提到,封装后的`UITextView`还支持设置文字样式,如字体和颜色,并能自适应高度,以及限制输入文字的最大高度和数量。 首先,我们来看自定义`placeholder`。`UITextView`原生并不提供占位符功能,但...
在iOS开发中,构建高度自适应的表单是常见的需求,尤其在处理用户输入和附件上传等场景。本文将深入探讨如何在iOS中实现这样一个高度封装的、支持编辑及附件功能的表单系统。 首先,我们需要理解表单的核心概念。在...
通过`UITextViewDemo`,开发者可以学习到如何在实际项目中灵活运用`UITextView`,特别是在高度自适应和用户交互方面,这些都是iOS开发中不可或缺的技能。项目的源代码将提供具体的实现细节和最佳实践,对于提升iOS...