一,效果图。
二,工程图。
三,代码。
RootViewController.h
RootViewController.m
myCell.h
#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
myCell.m
#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
CardViewController.h
#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
CardViewController.m
#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 = [