IOS自定义View的终结篇
发布日期:2021-11-21 04:40:56
浏览次数:33
分类:技术文章
本文共 3938 字,大约阅读时间需要 13 分钟。
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 ()3.运行结果如下{ 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
转载地址:https://blog.csdn.net/xiaoji94shen/article/details/20053819 如侵犯您的版权,请留言回复原文章的地址,我们会给您删除此文章,给您带来不便请您谅解!
发表评论
最新留言
第一次来,支持一个
[***.219.124.196]2024年04月10日 10时45分40秒
关于作者
喝酒易醉,品茶养心,人生如梦,品茶悟道,何以解忧?唯有杜康!
-- 愿君每日到此一游!
推荐文章
关于URL编码
2019-04-27
HTTP中的缓存
2019-04-27
Varnish 和 Squid比较到底强多少
2021-06-30
mysql常用语句集锦
2021-06-30
PHP的Smarty
2021-06-30
ecshop模板的原理分析
2021-06-30
深入探究Smarty模版
2021-06-30
PHP高效率写法(详解原因)
2021-06-30
PHP数组实际占用内存大小的分析
2021-06-30
PHP运行模式
2021-06-30
高性能Mysql主从架构的复制原理及配置详解
2021-06-30
深入理解php内核 编写扩展 I:介绍PHP和Zend
2019-04-27
LAMP 关键数据集锦技术选项参考
2019-04-27
HTTP POST慢速DOS攻击初探
2019-04-27
哈希表之殇
2019-04-27
MYSQL的MERGE存储引擎
2019-04-27
mysql 压力测试脚本
2019-04-27
PHP代码保护——Zend Guard
2019-04-27
浅谈https\ssl\数字证书
2019-04-27
Javassist 使用指南
2019-04-27