学习总结第二篇

来源:互联网 发布:php公众号自定义菜单 编辑:程序博客网 时间:2024/06/01 09:12
1,通过图片的地址获取到图片的名称
    第一种方法
    //拿到图片地址
   
NSString*urlStr = [self.movie.imagesobjectForKey:@"medium"];
   
//扩展:构建URL
   
NSURL *imgurl = [NSURLURLWithString:urlStr];
//    NSData *data = [NSData dataWithContentsOfURL:imgurl];
//    imgView.image = [UIImage imageWithData:data];
   第二种方法
   导入SDWebImage文件使用其中的UIImageView+WebCache.h文件
    //拿到图片地址
   
NSString*urlStr = [self.movie.imagesobjectForKey:@"medium"];
   
//扩展:构建URL
    NSURL *imgurl = [NSURLURLWithString:urlStr];
      [imgView sd_setImageWithURL:imgurl];
2,解析json数据
     + (id)requestData:(NSString*)filename
{
   
NSString*filePath = [[NSBundlemainBundle]pathForResource:filenameofType:@"json"];
   
   
NSData *data = [NSDatadataWithContentsOfFile:filePath];
   
   
NSError *error = nil;
   
id json =  [NSJSONSerializationJSONObjectWithData:dataoptions:NSJSONReadingMutableContainerserror:&error];
   
   
if (json == nil) {
       
NSLog(@"%@", error);
       
returnnil;
    }
else{
       
returnjson;
    } 
}
3,//拿到storyboard当中创建的控制器对象
           
           
UIStoryboard*storyboard = [UIStoryboardstoryboardWithName:@"Main"bundle:nil];
           
            NewsDetailViewController *detailVC = [storyboard instantiateViewControllerWithIdentifier:@"NewsDetailVC];//获取到storyboard中需要push的视图的storyboardID
           
            [self.navigationControllerpushViewController:detailVC animated:YES];
4, 当Push进此界面时,隐藏系统的tabbar
   self.hidesBottomBarWhenPushed= YES;
5, 拿到工程文件中的资源文件(以创建好的xib)
          NSBundle*bundle = [NSBundlemainBundle];
   
   
NSArray *xibs = [bundle loadNibNamed:@"MyView"owner:niloptions:nil];
   
   
UIView *view = [xibs lastObject];
   
   
CGRect rect1 = view.frame;
    rect1.
origin= CGPointMake(100,200);
    view.frame = rect1;
6,响应触摸事件,imageView,label的默认触摸事件为NO,其他的为YES
     button.userInteractionEnabled = NO;
7,图片的拉伸
    image1 = [image1 stretchableImageWithLeftCapWidth:5 topCapHeight:0];
//    image2 = [image2 stretchableImageWithLeftCapWidth:5 topCapHeight:0];
   
    image1 = [image1
resizableImageWithCapInsets:UIEdgeInsetsMake(0,5,0,5)];
    image2 = [image2 resizableImageWithCapInsets:UIEdgeInsetsMake(0,5, 0,5)];
8,加载百度
    UIWebView *webView = [[UIWebViewalloc]initWithFrame:self.view.bounds];
    //    //创建request对象
//    NSMutableURLRequest *mRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://www.baidu.com"]];
//   
//    //网页控件加载一个网络请求
//    [webView loadRequest: mRequest];
 
 9, 滑动到指定的单元格

    NSIndexPath *indexPath = [NSIndexPathindexPathForItem:self.indexinSection:0];
    [collectionView scrollToItemAtIndexPath:indexPath atScrollPosition:UICollectionViewScrollPositionCenteredHorizontallyanimated:NO];
10, 隐藏状态栏
- (BOOL)prefersStatusBarHidden
{
   
return self.navigationController.navigationBarHidden;
}
11,  //动态设置单元格的宽和高
- (
CGSize)collectionView:(UICollectionView*)collectionView layout:(UICollectionViewLayout*)collectionViewLayout sizeForItemAtIndexPath:(NSIndexPath*)indexPath
{
   
return CGSizeMake(self.pageWidth,self.height);
}
0 0
原创粉丝点击