ios - viewController的Push跳转,
黄舟
黄舟 2017-04-17 13:41:07
0
1
636
这是我创建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方法,但是页面上就是不从我的上一个页面跳转过来,
这是什么原因,有知道的么,

黄舟
黄舟

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

reply all(1)
刘奇

Because the styles are so different, I don’t understand your code very well. But from your description, could it be that the page is all ok, but there is only one step left to push or present?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!