第七课的主要内容:View Controller Lifecycle ImageView ScrollView WebView
1、View Controller Lifecycle
{
[super viewWillDisappear:animated]; // 这个要写
 [self rememberScrollPosition]; // 记住滚动的位置
[self saveDataToPermanentStore]; // maybe do in did instead?
// 注意不要在这里进行比耗时的操作,界面更流畅。
- (void)viewDidDisappear:(BOOL)animated;
- - (void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)anOrientation
- duration:(NSTimeInterval)seconds;
- - (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOriention)orient
- duration:(NSTimeInterval)seconds;
- - (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)anOrientation;
- @property UIInterfaceOrientation interfaceOrientati
- - (void)viewDidUnload
- {
- self.faceView = nil;
- }
view controller的初始化:
2、UIImageView
3、UIWebView
- - (void)loadRequest:(NSURLRequest *)request;
- - (void)loadHTMLString:(NSString *)string baseURL:(NSURL *)baseURL;
- - (void)loadData:(NSData *)data
- MIMEType:(NSString *)MIMEtype
- textEncodingName:(NSString *)encodingName
- baseURL:(NSURL *)baseURL;
- NSURLRequest
- + (NSURLRequest *)requestWithURL:(NSURL *)url;
- + (NSURLRequest *)requestWithURL:(NSURL *)url
- cachePolicy:(NSURLRequestCachePolicy)policy
- timeoutInterval:(NSTimeInterval)timeoutInterval;
4、ScrollView
- UIImage *image = [UIImage imageNamed:@"bigimage"];
- UIImageView *iv = [[UIImageView alloc] initWithImage:image];
- iv.frame = CGRectMake(0, 0, image.size.width, image.size.height) ;
- CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];
- UIScrollView *scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect];
- [scrollView addSubview:iv];
- scrollView.contentSize=CGSizeMake(2592 ,1952);
- [self.view addSubview:scrollView];
- -(void)scrollViewWillEndDragging:(UIScrollView *)scrollView withVelocity:(CGPoint)velocity targetContentOffset:(inout CGPoint *)targetContentOffset{
- CGPoint upperLeftOfVisible = scrollView.contentOffset;
- NSLog(@"x:%f, y:%f", upperLeftOfVisible.x, upperLeftOfVisible.y);
- }
- CGRect visibleRect = [scrollView convertRect:scrollView.bounds toView:subview];
UIScrollViewDelegate协议,
- UIImage *image = [UIImage imageNamed:@"bigimage"];
- imageView = [[UIImageView alloc] initWithImage:image];
- imageView.frame = CGRectMake(0, 0, image.size.width, image.size.height) ;
- CGRect fullScreenRect=[[UIScreen mainScreen] applicationFrame];
- UIScrollView *scrollView=[[UIScrollView alloc] initWithFrame:fullScreenRect];
- scrollView.delegate = self;
- scrollView.minimumZoomScale = 0.2;
- scrollView.maximumZoomScale = 2.0;
- [scrollView addSubview:imageView];
- scrollView.contentSize=CGSizeMake(2592 ,1952);
- [self.view addSubview:scrollView];
- - (UIView *)viewForZoomingInScrollView:(UIScrollView *)scrollView
- {
- return imageView;
- }
容芳志 (http://blog.youkuaiyun.com/totogo2010)
本文遵循“署名-非商业用途-保持一致”创作公用协议
原文地址:http://blog.youkuaiyun.com/totogo2010/article/details/8471739
1217



被折叠的 条评论
为什么被折叠?



