【代码笔记】iOS-UITableView上的button点击事件
代码。
ViewController.h

#import <UIKit/UIKit.h> @interface ViewController : UIViewController
<UITableViewDataSource,UITableViewDelegate>
{
UITableView *myTableView;
NSArray *dataArr;
} @end

ViewController.m

#import "ViewController.h"
#import "viewTableViewCell.h" @interface ViewController () @end @implementation ViewController - (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib. //UITableView
[self initTableView]; }
#pragma -mark -functions
-(void)initTableView
{ myTableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 100, 320, 400)];
myTableView.backgroundColor=[UIColor whiteColor];
myTableView.dataSource=self;
myTableView.delegate=self;
[self.view addSubview:myTableView]; }
#pragma -mark -UITableViewDelegate
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return 5;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *strID=@"cell";
viewTableViewCell *cell=(viewTableViewCell *)[tableView dequeueReusableCellWithIdentifier:strID];
if (nil==cell) {
cell=[[viewTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:strID];
}
[cell.btn addTarget:self action:@selector(doClickButton:) forControlEvents:UIControlEventTouchUpInside]; return cell; }
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 40; }
#pragma -mark -doClickButton
-(void)doClickButton:(UIButton *)btn
{
NSLog(@"--doClickButton-----");
} - (void)didReceiveMemoryWarning {
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
} @end

【代码笔记】iOS-UITableView上的button点击事件的更多相关文章
- Android笔记——Button点击事件几种写法
Button点击事件:大概可以分为以下几种: 匿名内部类 定义内部类,实现OnClickListener接口 定义的构造方法 用Activity实现OnClickListener接口 指定Button ...
- Android开发-之监听button点击事件
一.实现button点击事件的方法 实现button点击事件的监听方法有很多种,这里总结了常用的四种方法: 1.匿名内部类 2.外部类(独立类) 3.实现OnClickListener接口 4.添加X ...
- Android 使用代码主动去调用控件的点击事件(模拟人手去触摸控件)
使用代码主动去调用控件的点击事件(模拟人手去触摸控件) //View 可以是LinearLayout,Button,TextView View.performClick();
- Android学习-----Button点击事件几种写法
Button点击事件:大概可以分为以下几种: 匿名内部类 定义内部类,实现OnClickListener接口 定义的构造方法 用Activity实现OnClickListener接口 指定Button ...
- (转)Ext.Button点击事件的三种写法
转自:http://maidini.blog.163.com/blog/static/377627042008111061844345/ ExtJs的写法太灵活了,现在收集了关于Button点击事件的 ...
- UITableViewCell 上的按钮点击事件
以前做tableViewCell的button点击事件,总是建立一个全局的可变数组,把data放在数组里,点击获取button的tag值,根据tag从数组了里取data. 其实,如果section只 ...
- 两个堆叠fragment,上层fragment响应于降低fragment的button点击事件补救措施
加入onViewCreated的Touch事件监听, 以解决叠在一起的fragment上层响应下层的button点击事件解决方法 @Override public void onViewCreated ...
- Android实战简易教程-第十五枪(实现ListView中Button点击事件监听)
1.main.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" x ...
- IOS的UIWebView中JS点击事件,需要加入cursor:pointer;属性才可以
IOS的UIWebView中JS点击事件,需要加入cursor:pointer;属性才可以. Android的WebView可以支持外链样式,js文件:IOS则需要改为内嵌样式和JS文件.
随机推荐
- http://www.vaikan.com/docs/jquery.form.plugin/jquery.form.plugin.html#getting-started
http://www.vaikan.com/docs/jquery.form.plugin/jquery.form.plugin.html#getting-started Jquery.Form 异步 ...
- cFSMN和FSMN参数规模对比分析
1. FSMN参数规模分析 (1)分析前提: 假设隐藏层单元规模都为n 只分析前向t个时刻的结构,即暂时不考虑双向的结构 只分析向量系数编码,即vFSMN,暂时不考虑sFSMN ...
- iPhone X Web 设计
原文地址:https://webkit.org/blog/7929/designing-websites-for-iphone-x/ 开箱即用(开发者无需进行任何设置),在iPhone X中,Safa ...
- Webstorm使用教程详解
Webstorm使用教程详解 Webstorm垂直分栏.左右分栏 Webstorm 主题.背景.颜色等设置的导入导出 使用WebStorm开发web前端 网页中文乱码问题的解决方案 Webstor ...
- vim常用命令总结(转)
vim常用命令 -------------------------------------------------------------------------------------------- ...
- ABP集成WIF实现单点登录
ABP集成WIF实现单点登录 参考 ojlovecd写了三篇关于WIF文章. 使用WIF实现单点登录Part III —— 正式实战 使用WIF的一些开源示例. https://github.com/ ...
- 轻量级web富文本框——wangEditor使用手册(3)——如何自定义配置菜单 demo
最新版wangEditor: 配置说明:http://www.wangeditor.com/doc.html demo演示:http://www.wangeditor.com/wangEditor/d ...
- WebMagic实现分布式抓取以及断点抓取
访问我的博客 前言 从去年到今年,笔者主要负责的是与合作方的内容对接,新增的合作商不是很多的情况下,在我自从去年引入了 WebMagic 这个爬虫框架之后,基本很少需要去关注维护爬虫,做的最多的是新接 ...
- postgresql 常用命令
普通用法: sudo su - postgres 切换到postgres用户下: psql -U user -d dbname 连接数据库, 默认的用户和数据库是postgres \c dbname ...
- PHP 使用 GeoIP 进行不同国家 ip 测试
$ip = "67.220.91.30";// USA switch (mt_rand(0, 15)) { case 0:// India $ip = "210.212. ...