发布时间: 2012-06-20 20:37:21 作者: rapoo
如何让UITextView一直显示滚动条
http://www.cocoachina.com/bbs/simple/?t64154.html
//头文件#import <UIKit/UIKit.h>@interface TextView : UIView<UITextViewDelegate>{ UITextView *boxText;}- (id)initWithFrame:(CGRect)frame withContext:(NSString *)text;@end//实现文件@implementation TextView/** @method UITextView自定义重写封装 @param frame 位置 @param text 视图文本 */- (id)initWithFrame:(CGRect)frame withContext:(NSString *)text{ self = [super initWithFrame:frame]; if (self) { boxText = [[UITextView alloc] initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)]; boxText.delegate = self; [boxText setText:text]; [boxText setTextColor:[UIColor whiteColor]]; [boxText setTextAlignment:UITextAlignmentLeft]; [boxText setBackgroundColor:[UIColor clearColor]]; [boxText setFont:[UIFont systemFontOfSize:15]]; [boxText setEditable:YES]; [self addSubview:boxText]; [boxText release]; [NSTimer scheduledTimerWithTimeInterval:0.4 target:self selector:@selector(run) userInfo:nil repeats:NO]; } return self;}#pragma mark --视图移动后判断是否是UIImage,然后判断是否是竖滚动条设置让滚动条显示---(void)run{ [boxText setContentOffset:CGPointMake(0, 10) animated:NO]; for(UIView *img in [boxText subviews]){ if ([img isKindOfClass:[UIImageView class]] && img.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin){ [img setAlpha:1]; } }}#pragma mark --滚动视图结束移动后判断是否是UIImage,然后判断是否是竖滚动条设置让滚动条显示---(void)scrollViewDidEndDecelerating:(UIScrollView *)sc{ for (UIView *img in [sc subviews]) { if ([img isKindOfClass:[UIImageView class]] && img.autoresizingMask == UIViewAutoresizingFlexibleLeftMargin){ [img setAlpha:1]; } }}#pragma mark --禁止UITextView的选择和编辑--- (BOOL)textViewShouldBeginEditing:(UITextView *)textView{ return NO;}@end
20款移动开发框架平台介绍
微信公众平台如何保证access_token长期
中国城市列表相仿手机通讯录显示方式
Socket连接与HTTP联接
平添wifi定位功能
偷空写了两个游戏
java集合类 - 实现 细节
hidden visible display 的差别
春节前最后一个:立地群飞
64位 与32 位 差异