我有EAGLView,它是UIButton。在ViewController中,我需要在横向模式下显示相同的按钮,点击事件在EAGLView中有。我尝试设置[eaglView.save setFrame:CGRectMake(360,10,40,40)];但大小仍然没有改变,它仍然显示肖像模式框架。如何将EAGLView UIButton框架传递给视图控制器
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];
Viewcontroller.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 {
}
}
}
相同的代码也使用..检查我的代码在问题.. – user3602987