I've UIViewController and another UIView with some images and labels on it.
我想改变方向并且效果很好,我可以在旋转设备时更改 aqGridview框架,
我的代码:
- (void)makePortraitOrientation {
[gridView setFrame:CGRectMake(0, 43, 768,961)]; //works like a charm
HeaderView* dsd = [[HeaderView alloc] initWithParentID:self]; // in this way there is no errors but nothing changes
[dsd.label setFrame:CGRectMake(0, 0, 0, 0)];
[dsd setNeedsDisplay];
[self.HeaderView.label setFrame:CGRectMake(0, 0, 0, 0)]; //error, no object HeaderView in UIViewController
[self.HeaderView.label CGRectMake]
}
UIView的头文件
@interface HeaderView : UIView{
id parentID;
UIButton *menu;
UIImageView *icon;
NSString *product;
THLabel *label;
NSMutableArray *backs;
}
主要问题是如何更改图像的帧和位置 另一个UIView上的标签,而不是我的UIViewController?
所有以编程方式创建的视图。
答案 0 :(得分:0)
根据您的控制框架,您需要在旋转设备时调整控件的位置。
像这样在我们的视图控制器中的访问控件。 [self.button setFrame:];
访问子视图控件框架,如下所示:[self.subviewname.control setFrame:];
根据您需要处理框架的方向。您也可以使用自动重新调整大小。
更新: 确保您的子视图是否在视图控制器中正确添加,如下所示:
[self.view addSubView:self.mysubView]; 也增加子视图(HeaderView)的分数。