0

私は 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];

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 {

}

}

}
4

4 に答える 4

0

BooksEAGLEView.m

#import "BooksEAGLView.h"

@implementation BooksEAGLView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code

        save=[UIButton buttonWithType:UIButtonTypeCustom];
        [save setFrame:CGRectMake(240, 10, 50, 50)];
        [save setBackgroundColor:[UIColor redColor]];
        [save setTitle:@"Save" forState:UIControlStateNormal];
        [save addTarget:self action:@selector(save:) forControlEvents:UIControlEventTouchUpInside];
        [self addSubview:save];
    }
    return self;
}
-(void)save:(id)sender
{
    NSLog(@"clicked...");
}
于 2014-06-09T12:35:51.580 に答える
0

BooksEAGLView を呼び出しているビューコントローラーに次のコードを配置します。

- (void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)  interfaceOrientation duration:(NSTimeInterval)duration
{


    if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight){
        [eaglView.save setFrame:CGRectMake(360, 10, 40, 40)];

    }else {
         [eaglView.save setFrame:CGRectMake(240, 10, 50, 50)];
    }


}
于 2014-06-09T09:53:38.943 に答える