我有 EAGLView,它是 UIButton。在 ViewController 中,我需要在横向模式下显示与 EAGLView 中的单击事件相同的按钮。我试图设置 [eaglView.save setFrame:CGRectMake(360, 10, 40, 40)]; 但横向尺寸没有变化,仍然显示纵向模式框架。
EAGLView.h:
@interface BooksEAGLView : UIView{
UIButton *save;
}
@property(nonatomic, retain) UIButton *save;
EAGLView.mm:
save=[UIButton buttonWithType:UIButtonTypeCustom];
[save setImage:[UIImage imageNamed:@"share_1.png"] forState:UIControlStateNormal];
[save setFrame:CGRectMake(240, 10, 40, 40)];
[save addTarget:self action:@selector(save:) forControlEvents:UIControlEventTouchUpInside];
[self addSubview:save];
视图控制器.mm:
eaglView = [[BooksEAGLView alloc] initWithFrame:viewFrame delegate:self appSession:vapp];
[self setView:eaglView];
- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation) interfaceOrientation duration:(NSTimeInterval)duration
{
if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){
[eaglView.save setFrame:CGRectMake(360, 10, 40, 40)];
}else {
}
}
}