我的.xib文件中有三个视图 . 第一个是我的Viewcontroller的普通视图,没有子视图 .

然后我为肖像和风景创建相同的视图 . 这三个都必须是根级视图(看一下截图)

enter image description here

我的主要问题是我在.m文件中有一个IBAction,并且我在视图(纵向和横向)上使用UIButton使用相同的操作,因为我的两个视图具有相同的外观和完成相同的工作 .

点击运行后,模拟器显示纵向视图,我点击按钮工作,然后旋转模拟器,它显示横向视图,我点击按钮,它调用相同的IBAction并正常工作 .

但问题是,当我旋转模拟器三次然后纵向视图的buttopn工作正常但景观视图的按钮不起作用....什么是主要问题.....

#import "ViewController.h"

    @interface ViewController ()

    @end

    @implementation ViewController
    @synthesize landscapeView, portraitView ;

    @synthesize scrollView,pageControl,toolBar;

   - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
    {
        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
       if (self) {
                 // Custom initialization
         }
    return self;
    }

  - (void)viewDidLoad
    {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.

UIInterfaceOrientation interfaceOrientation=[[UIApplication sharedApplication]    statusBarOrientation];
[self setUpViewForOrientation:interfaceOrientation];
}


   -(void)willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
    {
[self setUpViewForOrientation:toInterfaceOrientation];
    }

   -(void)setUpViewForOrientation:(UIInterfaceOrientation)orientation
   {
[currentView removeFromSuperview];

if(UIInterfaceOrientationIsLandscape(orientation))
{
    [self.view addSubview:landscapeView];

    currentView = landscapeView;
}
else
{

    [self.view addSubview:portraitView];
     currentView = portraitView;


}

   }

     - (void)didReceiveMemoryWarning
    {
 [super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
    }

  -(IBAction)print:(id)sender
 {
NSLog(@"ok click ...");
 }


         @end

PLZ解决了吗????