can't display custom BarButton on toolbar

sunlite 2012-07-30 09:29:02
I used the following codes to the ZBar Reader Sample source code, then create a libzbar.a and added to my iOS App.But can't display custom BarButton on toolbar. Please help. thanks!

`ZBarReaderViewController.h

@interface ZBarReaderViewController: UIViewController
{IBOutlet UIButton *PowerButton;}

@property (nonatomic, assign) IBOutlet UIButton *PowerButton;

ZBarReaderViewController.m

@synthesize PowerButton;

CGRect frame1 = CGRectMake(150.0, 435.0, 50.0, 10.0);
PowerButton = [[UIButton alloc] initWithFrame:frame1];
UIImage *chatImage = [UIImage imageNamed:@"PowerButtonOn.png"];
PowerButton = [UIButton buttonWithType:UIButtonTypeCustom];
[PowerButton setImage:[UIImage imageNamed:@"PowerButtonOn.png"] forState:UIControlStateNormal];
[PowerButton setImage:[UIImage imageNamed:@"PowerButtonOff.png"] forState:UIControlStateSelected];
[PowerButton setBackgroundImage:chatImage forState:UIControlStateNormal];
[PowerButton addTarget:self action:@selector(PowerButtonPressed:) forControlEvents:UIControlEventTouchUpInside];
toolbar.items =[NSArray arrayWithObjects:[[[UIBarButtonItem alloc]
initWithBarButtonSystemItem: UIBarButtonSystemItemCancel
target: self
action: @selector(cancel)]
autorelease],
[[[UIBarButtonItem alloc]
initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace
target: nil
action: nil]
autorelease],
[[[UIBarButtonItem alloc] initWithCustomView:PowerButton] autorelease],
[[[UIBarButtonItem alloc]
initWithBarButtonSystemItem: UIBarButtonSystemItemFlexibleSpace
target: nil
action: nil]
autorelease], nil];
[controls addSubview: toolbar];
[toolbar release];
[view addSubview: controls];`
...全文
120 回复 打赏 收藏 转发到动态 举报
写回复
用AI写文章
回复
切换为时间正序
请发表友善的回复…
发表回复
已经博主授权,源码转载自 https://pan.quark.cn/s/008193215f29 在处理英文PDF文献进行阅读和翻译的过程中,常常会碰到一个挑战:文档内的换行标记可能干扰翻译的精确度。 这一现象的产生源于谷歌翻译等在线翻译服务在解析含换行符的内容时,常将其错误地解读为语句的终止点,进而引发翻译结果的偏差。 为了应对这一难题,我们可以运用若干实用策略来改善翻译流程。 下面介绍一种行之有效的方法:首先,需要将英文PDF文献中的文字信息进行复制。 这一操作可以通过两种途径实现:1. 利用PDF转WORD软件:众多第三方应用程序例如Adobe Acrobat或在线转换平台,能够协助我们将PDF资料转化为Word文档,从而获取无换行符的纯文本格式。 2. 直接从PDF文档提取:倘若PDF文件具备编辑属性,用户可以选取文本并执行复制动作,尽管这种方式有时仍会保留换行符,但后续可进行相应处理。 随后,建议采用WPS Office(国产办公应用)进行深入编辑。 WPS具备卓越的文本处理能力,可协助我们清除换行标记并优化段落布局。 具体操作步骤如下:1. 下载并安装WPS Office。 若个人电脑尚未安装该软件,可从其官方网站获取并完成安装流程。 2. 启动WPS的文字编辑模块。 在WPS中创建一个新文档,并将从PDF复制的文本粘贴至其中。 3. 在WPS的界面顶部,定位“开始”功能键,并点击进入。 4. 在“开始”功能区下,查找“文字工具”选项。 此功能集合提供了多种实用工具,有助于解决各类文本难题。 5. 在“文字工具”内,识别“删除空格”功能。 此步骤旨在移除文本中的所有空白字符,包括由换行产生的额外空格。 6. 继续选择“段落重排”功能。 该操作将依据实际语境自动调整文本的分句方式,确保每个句子的完整...

29,042

社区成员

发帖
与我相关
我的任务
社区描述
主要讨论与iOS相关的软件和技术
社区管理员
  • iOS
  • 大熊猫侯佩
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧