您的位置:首页 > 产品设计 > UI/UE

20141211笔记(UIImageView 设置内容的Mode的方法\UICollectionViewCell Custom的方法\ios modal segue code)

2014-12-10 23:03 609 查看
1、UIImageView设置内容的Mode的方法
imageView.contentMode=UIViewContentModeScaleAspectFill;

2、UICollectionViewCellCustom的方法
CustomUICollectionViewCell.m


-(id)initWithFrame:(CGRect)frame{
if(self=[superinitWithFrame:frame]){
[selfinitUI];
}
returnself;
}
-(void)initUI{
  //TODO
}


然后在collectionView中注册这个
CustomUICollectionViewCell


  UICollectionViewFlowLayout*flowLayout=[[UICollectionViewFlowLayoutalloc]init];
collectionView=[[UICollectionViewalloc]initWithFrame:CGRectZerocollectionViewLayout:flowLayout];
[collectionViewsetTranslatesAutoresizingMaskIntoConstraints:NO];
[collectionViewsetBackgroundColor:[UIColorclearColor]];
[collectionViewregisterClass:[CustomCollectionViewCellclass]forCellWithReuseIdentifier:@"MY_CELL"];
collectionView.dataSource=self;
collectionView.delegate=self;


最后在datasource函数中复用Cell

-(UICollectionViewCell*)collectionView:(UICollectionView*)cvcellForItemAtIndexPath:(NSIndexPath*)indexPath{
CustomCollectionViewCell*cell=[cvdequeueReusableCellWithReuseIdentifier:@"MY_CELL"forIndexPath:indexPath];

returncell;
}


这就是CollectionViewCell的Custom流程

3、iosmodalseguecode

-(IBAction)pushMyNewViewController
{
MyNewViewController*myNewVC=[[MyNewViewControlleralloc]init];

//doanysetupyouneedformyNewVC

[selfpresentModalViewController:myNewVCanimated:YES];//被弃用

    [selfpresentViewController:viewControlleranimated:YEScompletion:nil];//被这个代替

}

[selfdismissViewControllerAnimated:YEScompletion:nil];//dismissview


                                            
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐