1.完善上兩篇的東西,將一行的東西添加到UITableView中,這裏的TableView我是在storyboard中直接是用的
也沒什麼說的,就是改了界面展示和控制器而已,直接貼代碼
//
// IKEDMyOwnControllerViewController.m
// Ikefr
//
// Created by apple on 14-2-27.
// Copyright (c) 2014年 com.tyust. All rights reserved.
//
#import "IKEDMyOwnControllerViewController.h"
#import "IKEDMyOwnHorizenView.h"
@interface IKEDMyOwnControllerViewController ()<IKEDMyOwnHorizenViewDelegate>
{
NSArray *array;
}
@end
@implementation IKEDMyOwnControllerViewController
- (id)initWithStyle:(UITableViewStyle)style
{
self = [super initWithStyle:style];
if (self) {
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
array = @[@[ @{@"pic":@"1.jpg",@"title":@"A-1"},
@{@"pic":@"2.jpg",@"title":@"A-2"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"3.jpg",@"title":@"A-5"},
@{@"pic":@"4.jpg",@"title":@"A-6"},
@{@"pic":@"3.jpg",@"title":@"A-7"},
@{@"pic":@"4.jpg",@"title":@"A-8"},
@{@"pic":@"3.jpg",@"title":@"A-9"},
@{@"pic":@"4.jpg",@"title":@"A-10"},
@{@"pic":@"5.jpg",@"title":@"A-11"}
],
@[@{@"pic":@"1.jpg",@"title":@"A-1"},
@{@"pic":@"2.jpg",@"title":@"A-2"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"5.jpg",@"title":@"A-5"}
],
@[ @{@"pic":@"1.jpg",@"title":@"A-1"},
@{@"pic":@"2.jpg",@"title":@"A-2"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"3.jpg",@"title":@"A-3"},
@{@"pic":@"4.jpg",@"title":@"A-4"},
@{@"pic":@"5.jpg",@"title":@"A-5"}
]
];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return array.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
IKEDMyOwnHorizenView *view = [[IKEDMyOwnHorizenView alloc]initWithFrame:CGRectMake(0, 20, self.view.bounds.size.width, 120)];
view.delegate = self;
[view setImgData:[array objectAtIndex:indexPath.row]];
[cell addSubview:view];
return cell;
}
-(void)getData:(IKEDMyOwnHorizenView *)ikedView fromSelectedCellAtIndexpathString:(NSString *)str
{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"INFo" message:str delegate:self cancelButtonTitle:@"NO" otherButtonTitles:@"YES", nil];
[alert show];
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 150;
}
@end
3.運行結果如下