【代码笔记】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文件.
随机推荐
- mybatis使用中的记录
一: 常用sql语句: sql顺序:select [distinct] * from 表名 [where group by having order by limit]; 查询某段时间内的数据: ...
- 如何在vue中全局引入stylus文件的公共变量
新建 一个公共的stylus公共文件添加公共变量,如下: 修改下图圈出的文件: 具体的修改如下: // generate loader string to be used with extract t ...
- POJ 2719
#include<iostream> #include<stdio.h> using namespace std; ]; int _pow(int m,int n); int ...
- canvars 画花
index.html <!DOCTYPE html><html><head> <title>旋转的花</title> <meta ch ...
- 剑指offer十六之合并两个排序的链表
一.题目 输入两个单调递增的链表,输出两个链表合成后的链表,当然我们需要合成后的链表满足单调不减规则. 二.思路 注:链表1和链表2是两个递增排序的链表,合并这两个链表得到升序链表为链表3. 首先分析 ...
- 二分查找的实现(java版本)
一.二分法查找的定义 依次将所查找数据与中心数据对比,根据大小调整数据边界二.二分查找的条件 数组必须排序三.二分查找的原理 四.二分法查找的代码 /* * 从数组当中找到4所在的索引: * {2,4 ...
- opencv实现正交匹配追踪算法OMP
//dic: 字典矩阵: //signal :待重构信号(一次只能重构一个信号,即一个向量) //min_residual: 最小残差 //sparsity:稀疏度 //coe:重构系数 //atom ...
- (转) JVM Crash with SIGSEGV - problematic frame - libzip.so
原文:https://stackoverflow.com/questions/38057362/jvm-crash-with-sigsegv-problematic-frame-libzip-so h ...
- GitLab 修改主机名,更换 IP 配置,配置 SMTP
# find / -name gitlab.yml /opt/gitlab/embedded/service/gitlab-rails/config/gitlab.yml /var/opt/gitla ...
- Redis 缓存服务配置与使用
缓存服务器Couchbase另外一种选择Redis documentation http://redis.io/documentation http://redis.cn/documentation. ...