我已将uitableviewcell子类化,并通过layoutsubviews方法合并了一些子视图。所有视图都是在initWithStyle方法中分配和启动的,帧是在layoutSubViews方法中设置的,如下所示:
initWithStyle:... { UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectZero]; myLabel.someProperties = Configured; [self.contentView addSubview:myLabel]; layoutSubviews { CGRect labelRect = CGRectMake(10.0f, 5.0f, 35.0f, 180.0f); myLabel.frame = labelRect;
在viewcontroller中将shouldautrotateOrientation设置为yes会相应地旋转Navigationcontroller、TableView和uitoolbar,但TableViewCells的内容不会移动。我不清楚在哪里或什么地方可以添加到autoresizingmasks。到目前为止,我试过的组合还没有做过什么。有人能帮我一下吗?
谢谢!
我想出的答案是,在layoutsubviews方法中,根据方向使用条件编码来放置图幅
-(void)layoutSubviews { //For portrait mode (NOT PORTRAIT UPSIDE DOWN) if ( UIDeviceOrientationIsPortrait([[UIDevice currentDevice]orientation]) ) { CGRect portraitFrame = CGRectMake(Portrait Frame Coordinates); myLabel.frame = portraitFrame; } else { //For landscape modes CGRect landscapeFrame = CGRectMake(landscape frame coordinates); myLabel.frame = landscapeFrame; } }
似乎被黑在一起,但它在子类uitableviewcell中工作