【代码笔记】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文件.
随机推荐
- Synchronzied与ReentrantLock
- 【转】iOS中属性与成员变量的区别
[转载自并整理 http://blog.csdn.net/itianyi/article/details/8618128] 一.类Class中的属性property 在ios第一版中,我们为输出口同时 ...
- python _、__、__xx__之间的差别
默认情况下,Python中的成员函数和成员变量都是公开的(public),在python中没有类public,private等关键词来修饰成员函数和成员变量.其实,Python并没有真正的私有化支持, ...
- OSGI动态加载删除Service bundle
OSGi模块化框架是很早就出来的一个插件化框架,最早Eclipse用它而出名,但这些年也没有大热虽然OSGi已经发布了版本1到版本5.现在用的最多的,也是本文讲述基于的是Equinox的OSGi实现, ...
- 结构体访问成员变量什么时候该用“->”或者是"."呢?的困惑
煎蛋栗子: typedef struct Node{int data;struct Node *next;}LinkList; LinkList *p=(LinkList *)malloc(sizeo ...
- 代理模式——java设计模式
代理模式(Proxy Pattern) GoF中给出的代理模式的定义为: 代理模式给某一个对象提供一个代理或占位符,并由代理对象来控制对原对象的访问. 代理模式的英文叫做Proxy或Surrogate ...
- apache 的 配置项
一.主服务器部分 1.ServerName 指令 定义Apache默认主机名,(默认注释掉的),后面跟站点名,或是IP 例如:ServerName www.jone.com 或者 ServerNam ...
- sshd服务防止暴力破解
sshd防止暴力破解几种方式: 1.密码足够复杂 2.修改默认端口号 3.不适用root用户名登录. #是否可以禁止root身份登录?不行,因为有些程序需要使用root什么登录,另外判断一个用户是不是 ...
- Mysql的select in会自动过滤重复的数据
默认使用 SELECT 语句: 当加上in范围后,结果如下图: in范围内的数据,如果有重复的,只会选择第一个数据. 所以如果不是直接使用SQL语句来查询,而是在代码中来查询时,记得使用 distin ...
- AI---训练集(train set) 验证集(validation set) 测试集(test set)
在有监督(supervise)的机器学习中,数据集常被分成2~3个即: 训练集(train set) 验证集(validation set) 测试集(test set) 一般需要将样本分成独立的三部分 ...