ios开发总结(行高。tableviewcell禁止重用。隐藏状态栏。itms-services)

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不可重用,使得当为3identifier每次都不一样

       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里面的,只要把tableviewtableviewDelegatetableviewDataSource设置为一个controller就行了,并且这个controller必须实现这两种协议就好了。

5.iOS的模拟器并不支持itms-services协议的下载,想要测试下载是否成功,证书是否满足,必须使用真机测试。切记

6.

IOS 设置Launch image停留时间

- (void)viewDidLoad

{

   [superviewDidLoad];

    // Do anyadditional setup after loading the view, typically from a nib.

   [NSThreadsleepForTimeInterval:3.0];   //设置进程停止3秒

}

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;
    } }


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值