iOS为不同的button添加不同的方法

x_button = x_space + line * (x_space + buttonWidth);

y_button = y_space + row * (y_margin + buttonHeight);

NSString *title = dicArray[i][@"title"];

NSString *imageStr = dicArray[i][@"image"];

SEL selector = NSSelectorFromString(selectorArray[i]); // 反射机制,只要添加方法名的字符串,就能获得方法

HHSetButton *button = [HHSetButton buttonWithType:UIButtonTypeCustom];

[button addTarget:self action:selector forControlEvents:UIControlEventTouchUpInside];

时间: 2024-07-30 12:54:38

iOS为不同的button添加不同的方法的相关文章

iOS开发UI篇—Button基础

iOS开发UI篇—Button基础 一.简单说明 一般情况下,点击某个控件后,会做出相应反应的都是按钮 按钮的功能比较多,既能显示文字,又能显示图片,还能随时调整内部图片和文字的位置 二.按钮的三种状态 normal(普通状态) 默认情况(Default) 对应的枚举常量:UIControlStateNormal highlighted(高亮状态) 按钮被按下去的时候(手指还未松开) 对应的枚举常量:UIControlStateHighlighted disabled(失效状态,不可用状态) 如

iOS 开发之 为UIButton添加类别方法加载网络图片

iOS 开发之 为UIButton添加类别方法加载网络图片 使用GCD线程队列实现 工程如下: UIButton+WebCache.h #import <UIKit/UIKit.h> // 为Button添加类别方法 @interface UIButton (WebCache) - (void)xr_setButtonImageWithUrl:(NSString *)urlStr; @end UIButton+WebCache.m #import "UIButton+WebCache

ios runtime 动态向类添加方法

1.定义C函数: void dynamicMethodIMP(id self, SEL _cmd) { NSLog(@"蜗牛也疯狂"); } 2.重写函数+(BOOL)resolveInstanceMethod:(SEL)sel +(BOOL)resolveInstanceMethod:(SEL)sel { class_addMethod([self class], sel, (IMP)dynamicMethodIMP, "[email protected]:");

iOS 运行时添加属性和方法

原文链接http://blog.csdn.net/meegomeego/article/details/18356169第一种:runtime.h里的方法 BOOL class_addProperty(Class cls,constchar*name,constobjc_property_attribute_t*attributes,unsignedint attributeCount) #include <objc/runtime.h> #import <Foundation/Foun

IOS开发之自定义Button(集成三种回调模式)

前面在做东西的时候都用到了storyboard,在今天的代码中就纯手写代码自己用封装个Button.这个Button继承于UIView类,在封装的时候用上啦OC中的三种回调模式:目标动作回调,委托回调,Block回调.具体的内容请参考之前的博客:“Objective-C中的Block回调模式”,“Target-Action回调模式”,“Objective-C中的委托(代理)模式”.在接下来要封装的button中将要用到上面的知识点.之前在做新浪微博中的Cell的时候用到了Block回调来确定是那

Button 文字阴影,自定义图片,代码绘制样式,添加音效的方法

1.Button自己在xml文件中绑定监听器 <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent&qu

给button添加长按手势并侦测到此button

1, 添加手势 self.longPressRecognizer = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(handleLongPress:)];[btn addGestureRecognizer:self.longPressRecognizer]; 2,得到当前执行长点选的button - (void)handleLongPress:(UILongPressGestureRecogni

MFC 基础知识:对话框背景添加图片和按钮Button添加图片

很长时间没有接触MFC相关的知识了,我大概是在大二时候学习的MFC相关知识及图像处理,现在由于要帮个朋友完成个基于C++的程序,所以又回顾了下相关知识.的确,任何知识一段时间过后都比较容易忘记,但回顾起来还是很有印象的. 这篇文章主要是回顾以前的MFC基础知识,给对话框添加背景图片和给按钮button添加背景图片:希望此篇基础性文章对大家有所帮助!同时为下次做MFC相关知识提供点此时所想所感吧.内容比较简单,高手飘过~ 一. 对话框背景添加图片 首先通过VS2012创建MFC对话框应用程序,项目

WPF之路二 button添加背景图片点击后图片闪烁问题

在为button添加背景图片的时候,点击后发现图片闪烁,我们仔细观察,其实Button不仅仅只是在点击后会闪烁,在其通过点击或按Tab键获得焦点后都会闪烁,而通过点击其他按钮或通过按Tab键让Button失去焦点后就不闪烁了.如此我们可以推测出这不是点击或其他什么的问题而是焦点的问题,那么我们只要设置Button的Focusable属性为False就行了. 网上给的答案是要在button属性设置Focusable="False" ,无奈找属性栏里没有找到Focusable,于是在代码里