ios - viewController的Push跳转,
黄舟
黄舟 2017-04-17 13:41:07
0
1
637
这是我创建view的代码,

  _likeView = [[ClickImageView alloc] init];
_likeView.backgroundColor = [UIColor whiteColor];
[self addSubview:_likeView];

_likeButton = [UtilityFunc createButton:@"" frame:CGRectZero tag:0 imageName:@"home_departure_small_like.png" selectedImageName:@"home_departure_small_like_press.png" hightImageName:nil target:nil selector:nil];
[_likeView addSubview:_likeButton];

_likeNumLabel = [UtilityFunc createLabel:_likeNum frame:CGRectZero textColor:[UIColor quoteTextColor]];
_likeNumLabel.textAlignment = NSTextAlignmentLeft;
_likeNumLabel.backgroundColor = [UIColor clearColor];
_likeNumLabel.font = [UIFont mediumFont];
[_likeView addSubview:_likeNumLabel];


_commonView = [[ClickImageView alloc] init];
_commonView.backgroundColor = [UIColor whiteColor];
[self addSubview:_commonView];

_commentButton = [UtilityFunc createButton:@"" frame:CGRectZero tag:0 imageName:@"home_departure_small_comment.png" selectedImageName:@"home_departure_small_comment.png" hightImageName:nil target:nil selector:nil];
[_commonView addSubview:_commentButton];

_commentNumLabel = [UtilityFunc createLabel:_commonNum frame:CGRectZero textColor:[UIColor quoteTextColor]];
_commentNumLabel.textAlignment = NSTextAlignmentLeft;
_commentNumLabel.backgroundColor = [UIColor clearColor];
_commentNumLabel.font = [UIFont mediumFont];
[_commonView addSubview:_commentNumLabel];

这是tableview的cell里面的view的创建,
这里的view我代码里用的是masonry布局,所有一开始我这只是alloc,init出来,没有加frame,
frame的赋值是放到后面单另调的方法做的,

加frame的代码,

        CGFloat width = [UIImage imageNamed:@"home_departure_small_like.png"].size.width;
    CGFloat height = [UIImage imageNamed:@"home_departure_small_like.png"].size.height;

    [_likeView makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_locationImageView);
        make.left.equalTo(self.mas_right).offset(-SpaceAdapt(MARGIN_LEFT*11));
        make.size.mas_equalTo(CGSizeMake(width + SpaceAdapt(MARGIN_LEFT*2), height));
    }];

    [_likeButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_locationImageView.mas_centerY);
        make.left.equalTo(_likeView.mas_left).offset(0.f);
        make.size.mas_equalTo(CGSizeMake(_likeButton.currentBackgroundImage.size.width, _likeButton.currentBackgroundImage.size.height));
    }];

    [_likeNumLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_locationImageView.mas_centerY);
        make.left.equalTo(_likeButton.mas_right).offset(SpaceAdapt(MARGIN_LEFT/2));
        make.size.mas_equalTo(CGSizeMake(20, 20));

    }];


    [_commonView makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_locationImageView);
        make.left.equalTo(self.mas_right).offset(-SpaceAdapt(MARGIN_LEFT*6));
        make.size.mas_equalTo(CGSizeMake(width + SpaceAdapt(MARGIN_LEFT*2), height));
    }];

    [_commentButton makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_locationImageView.mas_centerY);
        make.left.equalTo(_commonView.mas_left).offset(0.f);
        make.size.mas_equalTo(CGSizeMake(_commentButton.currentBackgroundImage.size.width, _commentButton.currentBackgroundImage.size.height));
    }];

    [_commentNumLabel makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.equalTo(_locationImageView.mas_centerY);
        make.left.equalTo(_commentButton.mas_right).offset(SpaceAdapt(MARGIN_LEFT/2));
        make.size.mas_equalTo(CGSizeMake(20, 20));
    }];

这样子创建出来的view的点击事件,我的viewcontrller能对点击事件进行响应,但是这里我的viewcontroller要推出一个新的viewController,这里下一个viewcontroller已经进了viewdidLoad方法,但是页面上就是不从我的上一个页面跳转过来,
这是什么原因,有知道的么,

黄舟
黄舟

人生最曼妙的风景,竟是内心的淡定与从容!

全部回复(1)
刘奇

因为风格差别大,没怎么看懂你的代码,不过看你的描述,会不会是页面都ok了,就差一步push或者present了?

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责声明 Sitemap
PHP中文网:公益在线PHP培训,帮助PHP学习者快速成长!