iOS开发经验总结
1.防止tableviewcell重用引起的label显示重影现象。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger section = [indexPathsection];
NSInteger row = [indexPathrow];
NSString *identifier =nil;
NSArray * keysArray;
staticNSInteger time =0;
if( 0 == section){
//此identifier为模版,在storyboard里面定义的
identifier = @"substractTableCell";
keysArray = [_plantsSubstractDicallKeys];
}
elseif(1 == section){
identifier = @"progressTableCell";
keysArray = [_progressDicallKeys];
}else{
//打算在section==3时设定tableviewcell不可重用,使得当为3时identifier每次都不一样
time++;
identifier = [[NSStringalloc]initWithFormat:@"diffProgressTableCell%d",time];
// @"diffProgressTableCell";
keysArray = [_progressDiffDicallKeys];
}
UITableViewCell *cell = [tableViewdequeueReusableCellWithIdentifier:identifier];
if(0 == section){
}
elseif(1 ==section){
}elseif(2 ==section){
//重新创建cell,因为上一次的identifier与本次的不同,不可以重用
if(cell ==nil) {
cell = [[UITableViewCellalloc]initWithStyle:UITableViewCellStyleDefaultreuseIdentifier:identifier];
}
_eColumnChart =
[[EColumnChartalloc] initWithFrame:CGRectMake(40,50, cell.frame.size.width-80,
140)];
//[_eColumnChartsetNormalColumnColor:[UIColor purpleColor]];
[_eColumnChartsetColumnsIndexStartFromLeft:YES];
[_eColumnChartsetDelegate:self];
[_eColumnChartsetDataSource:self];
[_eColumnChart setShowHighAndLowColumnWithColor:NO];
UILabel *tempLabel1 =(UILabel *)[_eColumnChart viewWithTag:11];
tempLabel1.hidden =YES;
[tempLabel1 removeFromSuperview];
UILabel *tempLabel = [[UILabelalloc]initWithFrame:CGRectMake(230,20,50,30)];
[_eColumnChart addSubview:tempLabel];
[cell addSubview:_eColumnChart];
}
// Configure the cell...
returncell;
}
2.设定每行tableviewcell的高度
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(2 ==[indexPathsection])
return220;
else
return44;
}
3.不显示状态栏
- (BOOL)prefersStatusBarHidden
{
returnYES;
}
4.tableview不一定必须放置在tableviewcontroller里面的,只要把tableview的tableviewDelegate与tableviewDataSource设置为一个controller就行了,并且这个controller必须实现这两种协议就好了。
5.iOS的模拟器并不支持itms-services协议的下载,想要测试下载是否成功,证书是否满足,必须使用真机测试。切记
6.
IOS 设置Launch image停留时间
- (void)viewDidLoad
{
}
7.用到的图片的大小
launch image:r4:640*1136,2x:640*960
icon:29,40,60
8.适应屏幕的方法,此方法会在屏幕改变布局时调用
- (void)viewWillLayoutSubviews
{
if (UIInterfaceOrientationIsLandscape(self.interfaceOrientation))
{
CGRect rect = self.topLeftView.frame;
rect.size.width = 254;
rect.size.height = 130;
self.topLeftView.frame = rect;
rect = self.topRightView.frame;
rect.origin.x = 294;
rect.size.width = 254;
rect.size.height = 130;
self.topRightView.frame = rect;
rect = self.bottomView.frame;
rect.origin.y = 170;
rect.size.width = 528;
rect.size.height = 130;
self.bottomView.frame = rect;
}
else
{
CGRect rect = self.topLeftView.frame;
rect.size.width = 130;
rect.size.height = 254;
self.topLeftView.frame = rect;
rect = self.topRightView.frame;
rect.origin.x = 170;
rect.size.width = 130;
rect.size.height = 254;
self.topRightView.frame = rect;
rect = self.bottomView.frame;
rect.origin.y = 295;
rect.size.width = 280;
rect.size.height = 254;
self.bottomView.frame = rect;
} }