Gowhich

Durban's Blog

  • 按F1进入BIOS,选择Security ,选择 Secure Boot,进入后关闭 Secure Boot 为Disabled 即可!

  • 把Startup 的 UEFI/LEGACY BOOT 改为Both即可!

微软公司发布Win8系统以后,现在很多电脑厂商都把Win8系统出厂预装到笔记本当中,联想Thinkpad E430电脑也不例外,由于Win8系统的操作界面发生了很多改变,有很多人还不太喜欢使用电脑出厂预装的Win8系统,所以想要把Thinkpad E430电脑中出厂预装的Win8换成Win7的。

  对于笔记本电脑装系统,相信很多人都不陌生,但就有很多朋友问我,为什么我用U盘或是光盘对出厂预装了Win8系统的电脑安装系统,在按F12选择U盘或光盘启动的时候,老是进不去,画面闪动一下,又回到原来的界面,这是什么原因造成了的呢?

  有些人开始怀疑这是U盘或光盘坏了,或者是PE没有做好等原因,但拿到其它电脑上去,又成正常启动,这到底是那里出问题了呢?

  其实这不是你的U盘或PE出问题了,而是笔记本电脑预装Win8系统,采用了UEFI接口的原因,所以才会有一些PE无法兼容导致进不去,如果我们想要把预装的Win8系统换成Win7系统,我们只需要更改一下BIOS即可。

  • Win8换Win7更改BIOS的方法一:

  按开电源键,即可不停地按F1键,进入BIOS操作界面,按向右的方向键,选择“Security”,然后再按向下的方向键,选择最下面的“Secure Boot”,按回车键进入。

把“Secure Boot”中的“Enabled”按回车键更改成“Disabled”。

  按Esc键返回上一级菜单,再按向右方向键,选择“Startup”,把“UEFI/Legacy Boot”中的“UEFI Only”改成“Both”即可,按“Fn+F10”保存,然后就可以和其它电脑一样正常安装系统了。

  • Win8换Win7更改BIOS的方法二:

  同样是按电源键后,不停地按F1进入BIOS操作界面,按向右方向键选择“Restart”,然后再把“- OS Optimized Defaults”中的“Enabled”改成“Disabled”,在更改过程中,会弹出提示,我们选择YES即可。

  然后再按“Fn+F9”重置BIOS设置,重置完成以后,按再“Fn+F10”保存设置即可,这时就同没有预装Win8系统的电脑重装系统的方法是一样的了。

  注:你可以根据自己需要,随意选择上面其中一种更改BIOS中UEFI接口的方法,只要执行了上面其中某种方法的操作,即可顺种地通过U盘或光盘启动来更换Win8操作系统。

解决Win8系统换Win7以后,画面卡在“正在启动Windows”

  出厂预装Win8系统换成Win7,必须更换BIOS中的UEFI接口,然后再重装系统,但有人问我,系统通过ghost导入到电脑硬盘当中,重启时,画面就一直卡在“正在启动Windows”处,这是什么原因造成的。

  其实这主要是因为分区表错误的原因造成的,我们只需要运行PE系统的中DiskGenius分区工具,选择中电脑硬盘,再点文件边上的硬盘,在下拉菜单中点击“重建主引导记录(MBR)”即可,然后再按太阳城娱乐城正常操作对电脑硬盘进行重新分区并重装系统即可。

公司刚买了一台E430,将uefi/legacy boot,由默认uefi only 修改为both。不过,需要把security—secure boot中的secure boot 由默认Enables 修改为Disabled.只有这样修改以后,uefi/legacy boot才变成可以修改的项目。
如果想安XP,config—–serial ata(sata)中sata controller mode option由默认achi修改为compatibility.

来源:http://bbs.diannaodian.com/read-u-tid-161168.html

分词的这个技术,挺重要的,在有些方面起着非常重要的作用,这里摘自一博友的文章

PSCWS4 类对应的文件为 pscws4.class.php。在 PHP 代码中的调用方法如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
<?php
//加入头文件
require './pscws4/pscws4.class.php';

//建立分词类对像,参数为字符集,默认为gbk,
//可在后面调用set_charset改变
$pscws = new PSCWS4('utf8');

//接下来,设定一些分词参数或选项,set_dict 是必须的,
//若想智能识别人名等需要set_rule
//包括:set_charset,set_dict,set_rule,
//set_ignore,set_multi,set_debug,set_duality...等方法

$pscws->set_dict('./pscws4/etc/dict.xdb');
$pscws->set_rule('./pscws4/etc/rules.ini');

//分词调用send_text()将待分词的字符串传入,
//紧接着循环调用get_result()方法取回一系列分好的词
//直到get_result()返回false为止
//返回的词是一个关联数组,包含:word词本身,idf逆词率(重),
//off在text中的偏移,len长度,attr词性;
$pscws->send_text($text);
while($some = $pscws->get_result()) {
foreach($some as $word) {
print_r($word);
}
}

— 类方法完全手册 —

(注: 构造函数可传入字符集作为参数, 这与另外调用 set_charset 效果是一样的)

  • void set_charset(string charset);
    说明:设定分词词典、规则集、欲分文本字符串的字符集,系统缺省是 gbk 字集。
    返回:无。
    参数:charset 是设定的字符集,目前只支持 utf8 和 gbk。(注:big5 也可作 gbk 处理)
    注意:输入要切分的文本,词典,规则文件这三者的字符集必须统一为该 charset 值。

  • bool set_dict(string dict_fpath);
    说明:设置分词引擎所采用的词典文件。
    参数:dict_path 是词典的路径,可以是相对路径或完全路径。
    返回:成功返回 true 失败返回 false。
    错误:若有错误会给出 WARNING 级的错误提示。

  • void set_rule(string rule_path);
    说明:设定分词所用的新词识别规则集(用于人名、地名、数字时间年代等识别)。
    返回:无。
    参数:rule_path 是规则集的路径,可以是相对路径或完全路径。

  • void set_ignore(bool yes)
    说明:设定分词返回结果时是否去除一些特殊的标点符号之类。
    返回:无。
    参数:yes 设定值,如果为 true 则结果中不返回标点符号,如果为 false 则会返回,缺省为 false。

  • void set_multi(int mode);
    说明:设定分词返回结果时是否复合分割,如“中国人”返回“中国+人+中国人”三个词。
    返回:无。
    参数:mode 设定值,1 ~ 15。
    按位与的 1 | 2 | 4 | 8 分别表示: 短词 | 二元 | 主要单字 | 所有单字

  • void set_duality(bool yes);
    说明:设定是否将闲散文字自动以二字分词法聚合。
    返回:无。
    参数:yes 设定值,如果为 true 则结果中多个单字会自动按二分法聚分,如果为 false 则不处理,缺省为 false。

  • void set_debug(bool yes);
    说明:设置分词过程是否输出N-Path分词过程的调试信息。
    参数:yes 设定值,如果为 true 则分词过程中对于多路径分法分给出提示信息。
    返回:无。

  • void send_text(string text)
    说明:发送设定分词所要切割的文本。
    返回:无。
    参数:text 是文本的内容。
    注意:执行本函数时,请先加载词典和规则集文件并设好相关选项。

  • mixed get_result(void)
    说明:根据 send_text 设定的文本内容,返回一系列切好的词汇。
    返回:成功返回切好的词汇组成的数组, 若无更多词汇,返回 false。
    参数:无。
    注意:每次切割后本函数应该循环调用,直到返回 false 为止,因为程序每次返回的词数是不确定的。
    返回的词汇包含的键值有:word (string, 词本身) idf (folat, 逆文本词频) off (int, 在文本中的位置) attr(string, 词性)

  • mixed get_tops( [int limit [, string attr]] )
    说明:根据 send_text 设定的文本内容,返回系统计算出来的最关键词汇列表。
    返回:成功返回切好的词汇组成的数组, 若无更多词汇,返回 false。
    参数:limit 可选参数,返回的词的最大数量,缺省是 10;
    attr 可选参数,是一系列词性组成的字符串,各词性之间以半角的逗号隔开,
    这表示返回的词性必须在列表中,如果以~开头,则表示取反,词性必须不在列表中,
    缺省为空,返回全部词性,不过滤。

  • string version(void);
    说明:返回本版号。
    返回:版本号(字符串)。
    参数:无。

  • void close(void);
    说明:关闭释放资源,使用结束后可以手工调用该函数或等系统自动回收。
    返回:无。
    参数:无。

以下是相关资源的下载地址:
PSCWS4: http://www.ftphp.com/scws/down/pscws4-20081221.tar.bz2
规则集: http://www.ftphp.com/scws/down/scws-rules-all.zip
词典系列:http://www.ftphp.com/scws/down/scws-dict-chs-gbk.tar.bz2
http://www.ftphp.com/scws/down/scws-dict-chs-utf8.tar.bz2

查找好多了资料,对这个如果将自己定义的cell中的textfield实现,失去焦点触发键盘隐藏的功能,我这里简单的贴出自己的代码

第一部分是我的自定义的cell

nameCell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//
// nameCell.h
// xunYi6
//
// Created by david on 13-5-20.
// Copyright (c) 2013年 david. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface nameCell : UITableViewCell<UITextFieldDelegate>
@property (strong, nonatomic) IBOutlet UIImageView *markPic;
@property (strong, nonatomic) IBOutlet UILabel *teleplayName;
@property (strong, nonatomic) IBOutlet UITextField *teleplayInput;

@property (copy, nonatomic) UIImage *teleplayImage;
@property (copy, nonatomic) NSString *teleplayTitle;
@property (copy, nonatomic) NSString *name;

@end
nameCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
//
// nameCell.m
// xunYi6
//
// Created by david on 13-5-20.
// Copyright (c) 2013年 david. All rights reserved.
//

#import "nameCell.h"

@implementation nameCell

@synthesize teleplayImage = _teleplayImage;
@synthesize teleplayTitle = _teleplayTitle;
@synthesize name = _name;


- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
self.teleplayInput.delegate = self;
}
return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

-(void) setTeleplayImage:(UIImage *)value
{
if(![value isEqual:_teleplayImage])
{
_teleplayImage = [value copy];
self.markPic.image = _teleplayImage;
}
}

-(void) setTeleplayTitle:(NSString *)value
{
if(![value isEqualToString:_teleplayTitle])
{
_teleplayTitle = [value copy];
self.teleplayName.text = _teleplayTitle;
}
}

-(void) setName:(NSString *)value
{
if(![value isEqualToString:_name])
{

_name = [value copy];
self.teleplayInput.text = _name;
}
}

@end

实现的方法我实在-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section这个方法中实现的,代码如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.dataDic count];
}

-(UITableViewCell *) tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{


NSUInteger row = [indexPath row];

if(row == 0)
{
static NSString *nameCellIdentifier = @"nameCell";
UINib *nib = [UINib nibWithNibName:@"nameCell" bundle:nil];
[self.publicChanceTable registerNib:nib forCellReuseIdentifier:nameCellIdentifier];

nameCell *cell = [self.publicChanceTable dequeueReusableCellWithIdentifier:nameCellIdentifier];

if(cell == nil)
{
cell = [[nameCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:nameCellIdentifier];
}

cell.teleplayInput.delegate = self;

cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
return cell;
}

static NSString *cellIdentifier = @"cellIdentifier";

UITableViewCell *cell = [self.publicChanceTable dequeueReusableCellWithIdentifier:cellIdentifier];

if(cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
}

NSDictionary *dic = [self.dataDic objectForKey:[NSString stringWithFormat:@"%d",row]];
cell.textLabel.text = [dic valueForKey:@"detail"];

return cell;
}

重要的一点是我加入了这条语句

1
cell.teleplayInput.delegate = self;

同时在你的.h文件中要做的是:

1
@interface chancePublicViewController : UIViewController<UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate>

没错要引入UITextFieldDelegate协议

当通过 TCP/IP 连接 MySQL 远程主机时,出现 ERROR 2013 (HY000): Lost connection to MySQL server at 'reading initial communication packet', system error: 104

如果是在linux shell命令行中直接打 mysql 命令,能够顺利连上 MySQL,执行查询语句也比较正常,但如果执行 STOP SLAVE; 命令时就随机出现 ERROR 2013 (HY000): Lost connection to MySQL server during query 问题。而如果把操作命令写到脚本文件再去执行该脚本文件的话,则必然出现 Lost connection to MySQL server at 'reading initial communication packet', system error: 111

要是无论通过什么途径远程访问都出现错误可以认为是系统有防火墙之类的限制,但现在这种奇怪的抽筋现象让人百思不得其解。最后找到的解决方法是在 my.cnf 里面的 [mysqld] 段增加一个启动参数skip-name-resolve 问题消失。但原因还是想不出所以然。

产生的原因是 my.cnf 中我设置了 skip-name-resolveskip-name-resolve是禁用dns解析,所以在mysql的授权表中就不能使用主机名了,只能使用IP 。

基于要实现切库,而且又要使用Qeephp这个框架,之前一直没有用过,这里最近师兄在搞这一块,他的实现过程是这样的。详见以下代码:

1
2
3
4
5
6
7
8
<?php
Q::register(QDB::getConn('xxxxx'), 'dbo_default');
$select = XXXXX::find($sql)->order('id DESC')->all()->asArray()->limit(0, 10);
$this->_view['pager'] = $select->getPagination();
$this->_view['rowset'] = $select->getAll();

$model = Q::ini('app_config/RUN_MODE');
Q::register(QDB::getConn($model, 'dbo_default'));

这篇文章跟我之前讲的一篇文章是一样的,唯独不同的一点是,在编辑的状态进行拖动的时候,cell有重载的现象,这样导致的结果是,编辑状态缩进的cell又回复了原来的状态,使得原来的效果又回复了,这次,经过资料的查找,找打解决的办法,代码贴到下面了。至于自定的cell的话,大家可以自己去模仿制作一个,应该是没什么区别的。

attentionListCell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// attentionListCell.h
// xunYi6
//
// Created by david on 13-5-16.
// Copyright (c) 2013年 david. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface attentionListCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIImageView *imageViewPic;
@property (strong, nonatomic) IBOutlet UILabel *name;
@property (strong, nonatomic) IBOutlet UILabel *index;
@property (strong, nonatomic) IBOutlet UILabel *rank;

@property (copy, nonatomic) UIImage *listImage;
@property (copy, nonatomic) NSString *listName;
@property (copy, nonatomic) NSString *listIndex;
@property (copy, nonatomic) NSString *listRank;
//--------------------------
//编辑操作
//--------------------------
@property (strong, nonatomic) UIImageView *checkImageView;
@property (nonatomic) BOOL checked;
- (void) setChecked:(BOOL)checked;
@end
attentionListCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
//
// attentionListCell.m
// xunYi6
//
// Created by david on 13-5-16.
// Copyright (c) 2013年 david. All rights reserved.
//

#import "attentionListCell.h"

@implementation attentionListCell

@synthesize listImage = _listImage;
@synthesize listName = _listName;
@synthesize listIndex = _listIndex;
@synthesize listRank = _listRank;

@synthesize checkImageView = _checkImageView;
@synthesize checked = _checked;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

-(void) setListImage:(UIImage *)value
{
if(![value isEqual:_listImage])
{
_listImage = [value copy];
self.imageViewPic.image = _listImage;
}
}

-(void) setListName:(NSString *)value
{
if(![value isEqualToString:_listName])
{
_listName = [value copy];
self.name.text = _listName;
}
}

-(void) setListIndex:(NSString *)value
{
if(![value isEqualToString:_listIndex])
{
_listIndex = [value copy];
self.index.text = _listIndex;
}

}

-(void) setListRank:(NSString *)value
{
if(![value isEqualToString:_listRank])
{
_listRank = [value copy];
self.rank.text = _listRank;
}
}

-(void) willTransitionToState:(UITableViewCellStateMask)state{
[UIView beginAnimations:@"ResetFrame" context:nil];
[UIView setAnimationDuration:0.7];
[UIView setAnimationTransition:UIViewAnimationTransitionNone forView:self cache:NO];

if(state == UITableViewCellStateDefaultMask)
{
[self setSubViewsFrameNormal];
}
else if(state == UITableViewCellStateShowingEditControlMask)
{
[self setSubViewsFrameEdit];
}
else if(state == UITableViewCellStateShowingDeleteConfirmationMask)
{
[self setSubViewsFrameEdit];
}

[UIView commitAnimations];


}

-(void) setSubViewsFrameEdit{
CGFloat offset = 10.0;

CGFloat imageX = 5.0 + offset;
CGFloat imageY = 5.0;
CGFloat imageWidth = 60.0;
CGFloat imageHeight = 60.0;

CGFloat nameX = 70.0 + offset;
CGFloat nameY = 5.0;
CGFloat nameWidth = 240.0 - offset;
CGFloat nameHeight = 15.0;

CGFloat indexX = 70.0 + offset;
CGFloat indexY = 25.0;
CGFloat indexWidth = 240.0 - offset;
CGFloat indexHeight = 15.0;

CGFloat rankX = 70.0 + offset;
CGFloat rankY = 45.0;
CGFloat rankWidth = 240.0 - offset;
CGFloat rankHeight = 15.0;

[self.imageViewPic setFrame:CGRectMake(imageX, imageY, imageWidth, imageHeight)];

[self.name setFrame:CGRectMake(nameX, nameY, nameWidth, nameHeight)];

[self.index setFrame:CGRectMake(indexX, indexY, indexWidth, indexHeight)];

[self.rank setFrame:CGRectMake(rankX, rankY, rankWidth, rankHeight)];

}

-(void) setSubViewsFrameNormal{
CGFloat offset = 0.0;

CGFloat imageX = 5.0 + offset;
CGFloat imageY = 5.0;
CGFloat imageWidth = 60.0;
CGFloat imageHeight = 60.0;

CGFloat nameX = 70.0 + offset;
CGFloat nameY = 30.0;
CGFloat nameWidth = 240.0 - offset;
CGFloat nameHeight = 15.0;

CGFloat indexX = 70.0 + offset;
CGFloat indexY = 25.0;
CGFloat indexWidth = 240.0 - offset;
CGFloat indexHeight = 15.0;

CGFloat rankX = 70.0 + offset;
CGFloat rankY = 45.0;
CGFloat rankWidth = 240.0 - offset;
CGFloat rankHeight = 15.0;

[self.imageViewPic setFrame:CGRectMake(imageX, imageY, imageWidth, imageHeight)];

[self.name setFrame:CGRectMake(nameX, nameY, nameWidth, nameHeight)];

[self.index setFrame:CGRectMake(indexX, indexY, indexWidth, indexHeight)];

[self.rank setFrame:CGRectMake(rankX, rankY, rankWidth, rankHeight)];
}

//-------------------------------
// 重新定义editing的设置
//-------------------------------
-(void) setEditing:(BOOL)editing animated:(BOOL)animated{

if (self.editing == editing)
{
return;
}

[super setEditing:editing animated:animated];

if (editing)
{
CGFloat offset = 10.0;

CGFloat imageX = 5.0 + offset;
CGFloat imageY = 5.0;
CGFloat imageWidth = 60.0;
CGFloat imageHeight = 60.0;

CGFloat nameX = 70.0 + offset;
CGFloat nameY = 5.0;
CGFloat nameWidth = 240.0 - offset;
CGFloat nameHeight = 15.0;

CGFloat indexX = 70.0 + offset;
CGFloat indexY = 25.0;
CGFloat indexWidth = 240.0 - offset;
CGFloat indexHeight = 15.0;

CGFloat rankX = 70.0 + offset;
CGFloat rankY = 45.0;
CGFloat rankWidth = 240.0 - offset;
CGFloat rankHeight = 15.0;

[self.imageViewPic setFrame:CGRectMake(imageX, imageY, imageWidth, imageHeight)];

[self.name setFrame:CGRectMake(nameX, nameY, nameWidth, nameHeight)];

[self.index setFrame:CGRectMake(indexX, indexY, indexWidth, indexHeight)];

[self.rank setFrame:CGRectMake(rankX, rankY, rankWidth, rankHeight)];

if(_checkImageView == nil){
_checkImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Unselected.png"]];
[self addSubview:_checkImageView];
[_checkImageView setFrame:CGRectMake(5.0, self.index.frame.origin.y, 30.0, 30.0)];
}
[self setChecked:_checked];
}
else
{
_checked = NO;


if(_checkImageView == nil){
_checkImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Selected.png"]];
[self addSubview:_checkImageView];
[_checkImageView setFrame:CGRectMake(5.0, self.index.frame.origin.y, 30.0, 30.0)];
}
}

}

- (void) setChecked:(BOOL)checked
{
if (checked)
{
_checkImageView.image = [UIImage imageNamed:@"Selected.png"];
self.backgroundView.backgroundColor = [UIColor colorWithRed:223.0/255.0 green:230.0/255.0 blue:250.0/255.0 alpha:1.0];
}
else
{
_checkImageView.image = [UIImage imageNamed:@"Unselected.png"];
self.backgroundView.backgroundColor = [UIColor whiteColor];
}
_checked = checked;
}

@end

for…in…输出NSMutableDictionary(代码片段摘录如下)

1
2
3
4
5
6
7
8
9
NSString *path = [[NSBundle mainBundle] pathForResource:@"attention" ofType:@"plist"];
self.dataDic = [NSDictionary dictionaryWithContentsOfFile:path];
self.items = [NSMutableArray arrayWithCapacity:0];
for (id section in self.dataDic) {
Item *item = [[Item alloc] init];
item.title = [[self.dataDic objectForKey:section] valueForKey:@"title"];
item.isChecked = NO;
[_items addObject:item];
}

for…in…输出NSMutableArray(代码片段摘录如下)

1
2
3
4
for (NSDictionary *item in _items) {
NSLog(@"item.title = %@",[item valueForKey:@"title"]);
NSLog(@"item.isChecked = %@",[item valueForKey:@"isChecked"]);
}

网上搜索了很多,不知道是我搜索技术问题还是怎么着,就是没有找到,不过经过自己的努力,还是发现了解决的办法,因为这种情况大多数是自定的UITableviewCell,那么肯定知道如何自己的自定的cell里面如何修改cell上面的元素,其实原理很简单,就是重新设置一下元素的frame大小就好了,我讲自己的代码贴到下面希望能够给大家一个指引。如果问题,可以联系我跟我继续探讨。

attentionListCell.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
//
// attentionListCell.h
// xunYi6
//
// Created by david on 13-5-16.
// Copyright (c) 2013年 david. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface attentionListCell : UITableViewCell
@property (strong, nonatomic) IBOutlet UIImageView *imageViewPic;
@property (strong, nonatomic) IBOutlet UILabel *name;
@property (strong, nonatomic) IBOutlet UILabel *index;
@property (strong, nonatomic) IBOutlet UILabel *rank;

@property (copy, nonatomic) UIImage *listImage;
@property (copy, nonatomic) NSString *listName;
@property (copy, nonatomic) NSString *listIndex;
@property (copy, nonatomic) NSString *listRank;
//--------------------------
//编辑操作
//--------------------------
@property (strong, nonatomic) UIImageView *checkImageView;
@property (nonatomic) BOOL checked;
- (void) setChecked:(BOOL)checked;
@end
attentionListCell.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
//
// attentionListCell.m
// xunYi6
//
// Created by david on 13-5-16.
// Copyright (c) 2013年 david. All rights reserved.
//

#import "attentionListCell.h"

@implementation attentionListCell

@synthesize listImage = _listImage;
@synthesize listName = _listName;
@synthesize listIndex = _listIndex;
@synthesize listRank = _listRank;

@synthesize checkImageView = _checkImageView;
@synthesize checked = _checked;

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
if (self) {
// Initialization code
}
return self;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated
{
[super setSelected:selected animated:animated];

// Configure the view for the selected state
}

-(void) setListImage:(UIImage *)value
{
if(![value isEqual:_listImage])
{
_listImage = [value copy];
self.imageViewPic.image = _listImage;
}
}

-(void) setListName:(NSString *)value
{
if(![value isEqualToString:_listName])
{
_listName = [value copy];
self.name.text = _listName;
}
}

-(void) setListIndex:(NSString *)value
{
if(![value isEqualToString:_listIndex])
{
_listIndex = [value copy];
self.index.text = _listIndex;
}

}

-(void) setListRank:(NSString *)value
{
if(![value isEqualToString:_listRank])
{
_listRank = [value copy];
self.rank.text = _listRank;
}
}

- (void) setCheckImageViewCenter:(CGPoint)pt alpha:(CGFloat)alpha animated:(BOOL)animated
{
if (animated)
{
[UIView beginAnimations:nil context:nil];
[UIView setAnimationBeginsFromCurrentState:YES];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3];

_checkImageView.center = pt;
_checkImageView.alpha = alpha;

[UIView commitAnimations];
}
else
{
_checkImageView.center = pt;
_checkImageView.alpha = alpha;
}
}

//-------------------------------
// 重新定义editing的设置
//-------------------------------
-(void) setEditing:(BOOL)editing animated:(BOOL)animated{

if (self.editing == editing)
{
return;
}

[super setEditing:editing animated:animated];

if (editing)
{
// CGRect *imageFrame = self.imageViewPic.frame;


[self.imageViewPic setFrame:CGRectMake(self.imageViewPic.frame.origin.x + 30, self.imageViewPic.frame.origin.y, self.imageViewPic.frame.size.width, self.imageViewPic.frame.size.height)];

[self.name setFrame:CGRectMake(self.name.frame.origin.x + 30, self.name.frame.origin.y, self.name.frame.size.width, self.name.frame.size.height)];

[self.index setFrame:CGRectMake(self.index.frame.origin.x + 30, self.index.frame.origin.y, self.index.frame.size.width, self.index.frame.size.height)];

[self.rank setFrame:CGRectMake(self.rank.frame.origin.x + 30, self.rank.frame.origin.y, self.rank.frame.size.width, self.rank.frame.size.height)];

// [self.imageViewPic setFrame:CGRectMake(<#CGFloat x#>, <#CGFloat y#>, <#CGFloat width#>, <#CGFloat height#>)]

// self.selectionStyle = UITableViewCellSelectionStyleNone;
// self.backgroundView = [[UIView alloc] init];
// self.backgroundView.backgroundColor = [UIColor redColor];
// self.textLabel.backgroundColor = [UIColor clearColor];
// self.detailTextLabel.backgroundColor = [UIColor clearColor];
//
// if (_checkImageView == nil)
// {
// _checkImageView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Unselected.png"]];
// [self addSubview:_checkImageView];
// }
//
// [self setChecked:_checked];
// _checkImageView.center = CGPointMake(-CGRectGetWidth(_checkImageView.frame) * 0.5,
// CGRectGetHeight(self.bounds) * 0.5);
// _checkImageView.alpha = 0.0;
// [self setCheckImageViewCenter:CGPointMake(20.5, CGRectGetHeight(self.bounds) * 0.5)
// alpha:1.0 animated:animated];
}
else
{
// _checked = NO;
// self.selectionStyle = UITableViewCellSelectionStyleBlue;
// self.backgroundView = nil;
//
// if (_checkImageView)
// {
// [self setCheckImageViewCenter:CGPointMake(-CGRectGetWidth(_checkImageView.frame) * 0.5,
// CGRectGetHeight(self.bounds) * 0.5)
// alpha:0.0
// animated:animated];
// }
}

}

- (void) setChecked:(BOOL)checked
{
if (checked)
{
_checkImageView.image = [UIImage imageNamed:@"Selected.png"];
self.backgroundView.backgroundColor = [UIColor colorWithRed:223.0/255.0 green:230.0/255.0 blue:250.0/255.0 alpha:1.0];
}
else
{
_checkImageView.image = [UIImage imageNamed:@"Unselected.png"];
self.backgroundView.backgroundColor = [UIColor whiteColor];
}
_checked = checked;
}

@end

iOS实例-UIProgressView的简单实用方法

代码如下:

ProgressViewViewController.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
#import <UIKit/UIKit.h>
@interface ProgressViewViewController : UIViewController
{
UIProgressView *progressview;
UIProgressView *barprogressview;
NSTimer *timer;
IBOutlet UIButton *startButton;
IBOutlet UIButton *stopButton;
}

@property (nonatomic,retain) IBOutlet UIProgressView *progressview;
@property (nonatomic,retain) IBOutlet UIProgressView *barprogressview;
-(IBAction) startProgress:(id)sender;
-(IBAction) stopProgress:(id)sender;

@end
ProgressViewViewController.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
@implementation ProgressViewViewController

@synthesize progressview;
@synthesize barprogressview;

- (void)viewDidLoad
{
self.progressview=nil;
self.barprogressview=nil;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
stopButton.enabled = NO;
startButton.enabled = YES;
}

-(void) dealloc
{
self.progressview=nil;
self.barprogressview=nil;

[super dealloc];
}

- (void)viewDidUnload
{
self.progressview=nil;
self.barprogressview=nil;
[super viewDidUnload];
// Release any retained subviews of the main view.
}


/*进度条每次加0.01 */
-(void) timerChanged:(id)sender
{
self.progressview.progress +=0.01f;
self.barprogressview.progress +=0.01f;
}

-(IBAction) startProgress:(id)sender
{

timer=[NSTimer scheduledTimerWithTimeInterval:0.03f
target:self
selector:@selector(timerChanged:)
userInfo:nil
repeats:YES];
//[timer retain];
startButton.enabled = NO;
stopButton.enabled = YES;
}
-(IBAction) stopProgress:(id)sender
{
[timer invalidate];
//[timer release];
//timer =nil;

self.progressview.progress=0.0f;
self.barprogressview.progress=0.0f;

startButton.enabled = YES;
stopButton.enabled = NO;
}

这里提示一点是progress的最大值为1,最小值为0

1
2
NSString *tempA = @"123";
NSString *tempB = @"456";

字符串拼接

1
NSString *newString = [NSString stringWithFormat:@"%@%@",tempA,tempB];

字符转int

1
int intString = [newString intValue];

int转字符

1
NSString *stringInt = [NSString stringWithFormat:@"%d",intString];

字符转float

1
float floatString = [newString floatValue];

float转字符

1
NSString *stringFloat = [NSString stringWithFormat:@"%f",intString];
0%