星空网 > 软件开发 > 操作系统

【代码笔记】iCarouselDemo

一,效果图。

【代码笔记】iCarouselDemoimages/loading.gif' data-original="http://images2015.cnblogs.com/blog/337518/201510/337518-20151019151109583-575631649.jpg" width="217" height="400" />

二,工程图。

【代码笔记】iCarouselDemo

三,代码。

RootViewController.h

RootViewController.m

myCell.h

【代码笔记】iCarouselDemo
#import <UIKit/UIKit.h>#import <QuartzCore/QuartzCore.h>@interface myCell : UITableViewCell{  UILabel * myLable;  UIImageView * myImageView;  UILabel * title;}@property (strong,nonatomic) UILabel * myLabel;@property (strong,nonatomic) UIImageView * myImageView;@property (strong,nonatomic) UILabel * title;@end
【代码笔记】iCarouselDemo

 

myCell.m

【代码笔记】iCarouselDemo
#import "myCell.h"@implementation myCell@synthesize myLabel;@synthesize myImageView;@synthesize title;- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{  self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];  if (self) {        myLabel = [[UILabel alloc] init];    myLabel.lineBreakMode=NSLineBreakByCharWrapping;    myLabel.numberOfLines = 0;    myLabel.font = [UIFont fontWithName:@"MicrosoftYaHei" size:20.0];    [self addSubview:myLabel];        myImageView = [[UIImageView alloc] init];    [self addSubview:myImageView];        title = [[UILabel alloc] init];    title.frame = CGRectMake(10, 10, 50, 30);    title.backgroundColor = [UIColor colorWithRed:230/255.0 green:192/255.0 blue:203/255.0 alpha:1.0];    title.layer.cornerRadius = 10.0;    [self addSubview:title];    ;  }  return self;}- (void)setSelected:(BOOL)selected animated:(BOOL)animated{  [super setSelected:selected animated:animated];  // Configure the view for the selected state}@end
【代码笔记】iCarouselDemo

 

CardViewController.h

【代码笔记】iCarouselDemo
#import <UIKit/UIKit.h>@interface CardViewController : UIViewController<UITableViewDataSource,UITableViewDelegate>{  NSMutableArray *array ;  NSMutableArray * titleArray;}@property (strong ,nonatomic) NSMutableArray *array;@property (strong,nonatomic) NSString * month;@property (strong,nonatomic) NSString * imageName;@property (strong,nonatomic) NSString * title;@end
【代码笔记】iCarouselDemo

 

CardViewController.m

【代码笔记】iCarouselDemo
#import "CardViewController.h"#import "myCell.h"@interface CardViewController ()@end@implementation CardViewController@synthesize array;@synthesize month;@synthesize imageName;@synthesize title;- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil{  self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];  if (self) {    // Custom initialization  }  return self;}-(void)viewDidLoad{  [super viewDidLoad];      NSDictionary * dic1 = [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"BabyCard" ofType:@"plist"]];  self.array = [dic1 objectForKey:month];    NSDictionary * dic2 = [[NSDictionary alloc] initWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"Title" ofType:@"plist"]];  titleArray = [[NSMutableArray alloc] init];  titleArray = [dic2 objectForKey:title];    UITableView * tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0, 320, 460) style:UITableViewStylePlain];  tableView.delegate = self;  tableView.dataSource = self;  tableView.showsVerticalScrollIndicator = NO;  [self.view addSubview:tableView];      UIButton * back = [UIButton buttonWithType:UIButtonTypeCustom];  back.frame = CGRectMake(10, 10, 25, 31);  [back setImage:[UIImage imageNamed:@"back.png"] forState:UIControlStateNormal];  [back addTarget:self action:@selector(back) forControlEvents:UIControlEventTouchUpInside];  [tableView addSubview:back];}#pragma -mark -doClickActions-(void)back{  CATransition *animation = [CATransition animation];  animation.delegate = self;  animation.duration = 0.7;  animation.type = @"oglFlip";  animation.subtype = kCATransitionFromLeft;  [self.view.layer addAnimation:animation forKey:@"animation"];  [self.navigationController dismissViewControllerAnimated:YES completion:nil];}#pragma -mark -UITableViewDelegate-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{  return array.count;}-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{  NSString * str = [array objectAtIndex:indexPath.row];   CGSize size=[str boundingRectWithSize:CGSizeMake(300, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20.0]} context:nil].size;    if(indexPath.row == 0)  {     return size.height + 350;  }  else  {    return size.height + 60;  }}-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{  myCell * cell = [tableView dequeueReusableCellWithIdentifier:@"id"];  if(cell == nil){    cell = [[myCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:@"id"];  }    NSString * str = [array objectAtIndex:indexPath.row];  CGSize size=[str boundingRectWithSize:CGSizeMake(300, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:20.0]} context:nil].size;  cell.selectionStyle = UITableViewCellSelectionStyleNone;      NSString * str2 = [NSString stringWithFormat:@" %@ ",[titleArray objectAtIndex:indexPath.row]];  CGSize size2=[str boundingRectWithSize:CGSizeMake(300, 1000) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName: [UIFont systemFontOfSize:10.0]} context:nil].size;  cell.title.text = str2;  if(indexPath.row == 0){    cell.myImageView.hidden = NO;    cell.myImageView.image = [UIImage imageNamed:imageName];    cell.myImageView.frame = CGRectMake(0, 0, 320, 300);    cell.myLabel.frame = CGRectMake(10, 350, 300, size.height);    cell.title.frame = CGRectMake(10, 310, size2.width, 30);  }else{    cell.myImageView.hidden = YES;    cell.myLabel.frame = CGRectMake(10, 50, 300, size.height);    cell.title.frame = CGRectMake(10, 10,size2.width, 30);  }  cell.myLabel.text = str;  return cell;}@end
【代码笔记】iCarouselDemo




原标题:【代码笔记】iCarouselDemo

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

lazada本土店发货时效:https://www.goluckyvip.com/tag/85393.html
lazada菲律宾本土店:https://www.goluckyvip.com/tag/85394.html
lazada本土店铺收款:https://www.goluckyvip.com/tag/85395.html
lazada跨境本土店:https://www.goluckyvip.com/tag/85396.html
lazada本土店发货:https://www.goluckyvip.com/tag/85397.html
lazada马来本土店:https://www.goluckyvip.com/tag/85398.html
恐怖游轮2002 恐怖游轮2022:https://www.vstour.cn/a/365178.html
时尚电商平台Meesho拟融资3亿美元!:https://www.kjdsnews.com/a/1836524.html
相关文章
我的浏览记录
最新相关资讯
海外公司注册 | 跨境电商服务平台 | 深圳旅行社 | 东南亚物流