if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
cell.accessoryType = UITableViewCellAccessoryDetailButton;
cell.textLabel.font = [UIFont systemFontOfSize:19.0]; UIImage *image = [UIImage imageNamed:@"england"];
UIButton * button = [UIButton buttonWithType:UIButtonTypeCustom];
CGRect frame = CGRectMake(0.0,0.0,,);
button.frame = frame;
[button setBackgroundImage:image forState:UIControlStateNormal];
button.backgroundColor = [UIColor clearColor];
cell.accessoryView = button;
[button addTarget:self action:@selector(btnClicked:event:) forControlEvents:UIControlEventTouchUpInside];
}
- (void)btnClicked:(id)sender event:(id)event
{
NSSet * touches = [event allTouches];
UITouch * touch = [touches anyObject];
CGPoint currentTouchPosition = [touch locationInView:self.countriesTableView];
NSIndexPath * indexPath = [self.countriesTableView indexPathForRowAtPoint:currentTouchPosition];
if(indexPath != nil)
{
[self tableView:self.countriesTableView accessoryButtonTappedForRowWithIndexPath:indexPath];
}
}

设置imageView大小

    cell.imageView.image = [MainTableViewController scale:item.flag toSize:CGSizeMake(, )];
+ (UIImage *)scale:(UIImage *)image toSize:(CGSize)size
{
UIGraphicsBeginImageContext(size);
[image drawInRect:CGRectMake(, , size.width, size.height)];
UIImage * scaledImage = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
return scaledImage;
}

UITableview自定义accessory按钮和ImageView大小一致的更多相关文章

  1. [安卓] 18、一个简单的例子做自定义动画按钮和自定义Actionbar

    在做安卓UI的时候有时候需自定义具有动画效果的按钮或需要自定义一下actionbar~ 本节用一个简单的demo讲如何自定义具有动画效果的按钮,以及个性化的actionbar 下面是效果: 其中: △ ...

  2. 如何让 UITableViewCell 中的 imageView 大小固定

    UITableView可以算是使用频率最高的组件之一的,在开发过程中经常需要展示一些简单的信息列表常见列表布局 如图,很多页面其实就是这种展示结果,通常需要imageView,textLabel,de ...

  3. OC导航栏自定义返回按钮

    [iOS]让我们一次性解决导航栏的所有问题 在默认情况下,导航栏返回按钮长这个样子   导航栏默认返回按钮 导航栏左上角的返回按钮,其文本默认为上一个ViewController的标题,如果上一个Vi ...

  4. Mono自定义图片按钮

    首先,我们编写一个MyImageButton类,继承自LinearLayout public class MyPhoneImageButton:LinearLayout { private Image ...

  5. WPF自定义控件与样式(13)-自定义窗体Window & 自适应内容大小消息框MessageBox

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等,若有不明白的地方可以参考本系列前面的文章,文末附有部分文章链接. 本文主要内容: 自定义 ...

  6. android自定义控件(3)-自定义当前按钮属性

    那么还是针对我们之前写的自定义控件:开关按钮为例来说,在之前的基础上,我们来看看有哪些属性是可以自定义的:按钮的背景图片,按钮的滑块图片,和按钮的状态(是开还是关),实际上都应该是可以在xml文件中直 ...

  7. 自定义Qt按钮

    转自:http://blog.csdn.net/starcloud_zxt/article/details/5185556 Qt自带的PushButton样式比较单一,在开发的时候往往按钮的形状各异, ...

  8. 【转】WPF自定义控件与样式(13)-自定义窗体Window & 自适应内容大小消息框MessageBox

    一.前言 申明:WPF自定义控件与样式是一个系列文章,前后是有些关联的,但大多是按照由简到繁的顺序逐步发布的等. 本文主要内容: 自定义Window窗体样式: 基于自定义窗体实现自定义MessageB ...

  9. iOS 自定义返回按钮,保留系统滑动返回

    原文链接 自定义返回按钮保留系统滑动返回手势.gif 1.简介 使用苹果手机,最喜欢的就是用它的滑动返回.作为一个开发者,我们在编写很多页面的时候,总是会因为这样那样的原因使得系统的滑动返回不可用.使 ...

随机推荐

  1. perl的输出缓冲

      今天写一个小脚本的时候,需要即时输出当前进度到命令行上,并即时将重要数据写入报告文件中.但是perl默认是有输出缓冲的,显示到命令行上必须以\n结尾才行,输出到文件中,回车了都不行,非得要等缓冲区 ...

  2. gcc编译常用选项

    我的博客:www.while0.com GDB调试: -g 生成的可执行文件才可以用gdb调试 (建议在发行版中用strip filename 来把这些调试信息去除) 开始调试. 以下是基础调试命令: ...

  3. 《深入理解linux内核》第一章 序论

    硬链接的限制

  4. 【HDOJ】2103 Family planning

    题目挺有意思.虽然不是很难. #include <stdio.h> int main() { unsigned int m, n, case_n; unsigned ; scanf(&qu ...

  5. NTP 服务器配置

    1.yum安装ntp 1 yum install ntp* 2.更新时间 1 ntpdate 202.120.2.101 3.加入任务计划 1 2 crontab -e */10 * * * * nt ...

  6. phpMyAdmin 'import.php'跨站脚本漏洞

    漏洞版本: phpMyAdmin phpMyAdmin 3.4.9 phpMyAdmin phpMyAdmin 3.4.8 phpMyAdmin phpMyAdmin 3.4.6 phpMyAdmin ...

  7. Xcode 升级后, 插件无法使用的问题( PluginLoading: Required plug-in compatibility UUID.... )

    find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | x ...

  8. iOS添加自定义字体方法

    1:获取字体文件 从各种渠道下载字体文件ttf, 网站或者从别的ipa里扣出来.(以fzltxh.ttf为例) 2:将fzltxh.ttf文件拷贝到工程中 3:在Info.plist中添加项: Fon ...

  9. 对apache和memcache进行压力测试

    工作中经常使用的软件之二:apache和memcache 以前经常听说memcache的TPS能达到几万,但一直也不知道apache的性能到底如何,所以在闲暇之余,就自己做了一下压力测试. 环境:两台 ...

  10. 股票中的数学:EMA的推导01

    说明:本人并不炒股,原因很简单:没钱.当然了,作为一名IT工作者,因为工作需要和个人兴趣,就有了本系列文章.阅读本系列文章不需要任何高深的知识,哪怕是一个像我这样从未真正炒过股的人也没关系.但本文还是 ...