(iphone) when or how to get the uiview height size after layoutSubviews
in my viewcontrol开发者_StackOverflowler I make my instance of my view class ( in the viewdidload method) in that view class I implement the layoutsubviews method and add all kinds of subviews there
now since that view class is part of a uiscrollview i want to make the scrollview contentsize as large as the view class
how do i get the height of my viewclass?
tableInfo = [[TableInfoView alloc] initWithFrame:CGRectMake(10, 10, 300, 0)];
[scrollView addSubview:tableInfo];
NSLog(@"%f", tableInfo.height);
seems it doesn't automatically adjusts the frame height size or is it to soon to get the height ? .. i'm not quite sure.. because it displays correctly ..
how can i immediately call the layoutsubviews when i init the view class ?
It won't be immediate, but you can call the view's setNeedsLayout
method pretty much whenever you'd like in your controller's code. This will schedule the view for layout. (You really shouldn't ever be calling layoutSubviews
directly.)
精彩评论