我有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