项目总结小问题

2023-05-22,,

iPhone官方SDK:如何隐藏UINavigationBar

隐藏:

[self.navigationController setNavigationBarHidden:NO animated:YES];

显示:

[self.navigationController setNavigationBarHidden:YES animated:YES];

隐藏返回键
      self.navigationItem.hidesBackButton = YES;

在手势代理方法里加以判断

- (BOOL)gestureRecognizer:(UIGestureRecognizer*)gestureRecognizer shouldReceiveTouch:(UITouch *)touch

{

    return !([touch.view isKindOfClass:[UIControl class]]);

}

uilabel 添加点击事件

UITapGestureRecognizer *tapGestureTel = [[[UITapGestureRecognizeralloc]initWithTarget:self action:@selector(teleButtonEvent:)]autorelease];

    [telephoneLabel addGestureRecognizer:tapGestureTel];

collectionView

/*------------类目详细列表----------*/
    
    UICollectionViewFlowLayout *flowLayout = [[UICollectionViewFlowLayout alloc] init];
//    flowLayout.itemSize = CGSizeMake(63, 75);  //三列的
    flowLayout.itemSize = CGSizeMake(100, 120);
    flowLayout.scrollDirection = UICollectionViewScrollDirectionVertical;  //滚动方向的设置--垂直
//    flowLayout.scrollDirection = UICollectionViewScrollDirectionHorizontal; //滚动方向  --水平
    flowLayout.minimumLineSpacing = 10;
    
    self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(95, 108, 215, 426) collectionViewLayout:flowLayout];
    self.collectionView.backgroundColor = [UIColor whiteColor];
    self.collectionView.delegate = self;
    self.collectionView.dataSource = self;
//    self.collectionView.showsHorizontalScrollIndicator = NO;  //隐藏水平滚动条
    self.collectionView.showsVerticalScrollIndicator = NO;     //隐藏垂直滚动条
    [self.collectionView registerClass:[MyUICollectionViewCell class] forCellWithReuseIdentifier:@"aaa"];
    [self.view addSubview:self.collectionView];
    [flowLayout release];
    [_collectionView release];

NSNumber * time= listModel.lastUptrackAt;
    NSDate *date = [[[NSDate alloc]initWithTimeIntervalSince1970:[time doubleValue]/1000.0]autorelease]; //把毫秒的时间转化成时间
    NSDateFormatter *dateFormatter = [[[NSDateFormatter alloc] init] autorelease];
    dateFormatter.dateFormat = @"yyyy-MM-dd";
    NSString *date2 = [dateFormatter stringFromDate:date];  //把时间进行格式化
    cell.labelTime.text = [NSString stringWithFormat:@"最后更新:%@",date2];

    

    

ios设置tableview默认选中第一行并实现点击第一行的效果

    //如果有数据,默认选中第一行并请求第一行的数据    
        if(self.tableViewData.count>0)    
        {    
            [self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0] animated:YES scrollPosition:UITableViewScrollPositionTop];//设置选中第一行(默认有蓝色背景)    
            [self tableView:self.tableView didSelectRowAtIndexPath:[NSIndexPath indexPathForItem:0 inSection:0]];//实现点击第一行所调用的方法    
        }