iOS复习UIScoreView
- (void)viewDidLoad
{
[superviewDidLoad];
UIScrollView *scrollview =[[UIScrollView alloc]initWithFrame:CGRectMake(50,0,200,400)];
scrollview.contentSize=CGSizeMake(200,3800);//滑动的范围
scrollview.backgroundColor=[UIColorblueColor];
scrollview.directionalLockEnabled = YES;//这句话需要查查什么意思,注释也可以用
scrollview.pagingEnabled=YES;//是否自己动适应
[self.view addSubview:scrollview];
UITextField *viewA=[[UITextFieldalloc]initWithFrame:CGRectMake(50,0,200,800)];
viewA.textColor = [UIColor redColor];
viewA.text = @"213";
//viewA.backgroundColor=[UIColor blueColor];
[scrollview addSubview:viewA];
// UIScrollView *sv = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0, 0.0, self.view.frame.size.width, 400)];
// sv.pagingEnabled = YES;//可以拖动
// sv.maximumZoomScale=2.0;
// sv.minimumZoomScale=0.5;
// sv.backgroundColor = [UIColor blueColor];//设置背景颜色
// sv.showsVerticalScrollIndicator = NO;//是否显示水平拖动条
// sv.showsHorizontalScrollIndicator = NO;//是否显示竖直拖动条
// sv.delegate = self;
// CGSize newSize = CGSizeMake(self.view.frame.size.width * 2, self.view.frame.size.height);
//
// //canCancelContentTouches:YES-移动手指足够长度触发滚动事件,NO-scrollView发送 tracking events 后,就算用户移动手指,scrollView也不会滚动。
// sv.canCancelContentTouches=NO;
// //当值是 YES的时候,用户触碰开始.要延迟一会,看看是否用户有意图滚动。假如滚动了,那么捕捉 touch-down事件,否则就不捕捉。假如值是NO,当用户触碰, scroll view会立即触发
// sv.delaysContentTouches=YES;
// //ContentSize的意思就是它所有内容的大小,这个和它的Frame是不一样的,只有ContentSize的大小大于Frame这样才可以支持拖动。
// [sv setContentSize:newSize];
// [self.view addSubview: sv];
//
// UITextView *textView=[[UITextView alloc]initWithFrame:CGRectMake(200, 200, 400, 400)];
// textView.text=@"dsfjkhdhskjfhkj";
// textView.font=[UIFont systemFontOfSize:100];
// [self.view addSubview:textView];
// //为什么不可以拖动,还有很多注意点
}
//#pragma mark UIScrollViewDelegate
////只要滚动了就会触发
//- (void)scrollViewDidScroll:(UIScrollView *)scrollView;
//{
// // NSLog(@" scrollViewDidScroll");
// NSLog(@"ContentOffset x is %f,yis %f",scrollView.contentOffset.x,scrollView.contentOffset.y);
//}
////开始拖拽视图
//- (void)scrollViewWillBeginDragging:(UIScrollView *)scrollView;
//{
// NSLog(@"scrollViewWillBeginDragging");
//}
////完成拖拽
//- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate;
//{
// NSLog(@"scrollViewDidEndDragging");
//}
////将开始降速时
//- (void)scrollViewWillBeginDecelerating:(UIScrollView *)scrollView;
//{
// NSLog(@"scrollViewWillBeginDecelerating");
//}
//
////减速停止了时执行,手触摸时执行执行
//- (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView;
//{
// NSLog(@"scrollViewDidEndDecelerating");
//}
////滚动动画停止时执行,代码改变时出发,也就是setContentOffset改变时
//- (void)scrollViewDidEndScrollingAnimation:(UIScrollView *)scrollView;
//{
// NSLog(@"scrollViewDidEndScrollingAnimation");
//}
////设置放大缩小的视图,要是uiscrollview的subview
//- (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView;
//{
// NSLog(@"viewForZoomingInScrollView");
// return viewA;
//}
////完成放大缩小时调用
//- (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale;
//{
// viewA.frame=CGRectMake(50,0,100,400);
// NSLog(@"scale between minimum and maximum. called after any 'bounce' animations");
//}// scale between minimum and maximum. called after any 'bounce' animations
//
////如果你不是完全滚动到滚轴视图的顶部,你可以轻点状态栏,那个可视的滚轴视图会一直滚动到顶部,那是默认行为,你可以通过该方法返回NO来关闭它
//- (BOOL)scrollViewShouldScrollToTop:(UIScrollView *)scrollView;
//{
// NSLog(@"scrollViewShouldScrollToTop");
// return YES;
//}
//
//- (void)scrollViewDidScrollToTop:(UIScrollView *)scrollView;
//{
// NSLog(@"scrollViewDidScrollToTop");
//}
//
//- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
//{
// // Return YES for supported orientations
// return (interfaceOrientation == UIInterfaceOrientationPortrait);
//}
这个也是简单的实现,还需要深入了解,这些都是前几天复习写的,后来整理的,原本没打算写博客
2013年8月7日,12:36,东南大学无锡分校桃园3宿舍106室