简体   繁体   中英

Setting frame for subview's subview

I have view controller defined by xib.

In this view controller I add subclassed UIView. On this subclassed UIView I want to add another uiview.

I have variable nextRound that is of my custom view data type. I init it like:

    NSArray *subviewArray = [[NSBundle mainBundle] loadNibNamed:@"FDCOStaticNextRound" owner:self options:nil];
    nextRound = [subviewArray objectAtIndex:0];
    nextRound.frame =  CGRectZero;
    nextRound.alpha = 0.8;
    [self addSubview:nextRound];

After putting breakpoints, nextRound's frame is indeed 0,0,0,0 however, it is added with it's xib's frame (0,0,320,91).

I try to animate it when reaching next rounds (so it is presented for couple of seconds, and then dismissed with rollup/down animation). However even changing frame there seems to do nothing. Breakpoint-wise, frame changes, but actual view on screen doesn't do anything.

Autolayout is turned off, size inspector - autosizing is set only to top left. I've got similar feature right in view controller, and there, it works flawlessly, so I guess it has to do something with it being added to another custom view.

I managed to figure it out. In my xib(attribute inspector), I didn't have option clip subviews enabled :-/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM