1

像往常一样,我再次遇到一个非常简单的问题,但在这里压力很大。只是一个简单的案例:我即将在两个视图之间切换,但只能横向(左和右)。实际上,当我使用矩形按钮直接切换并使用相同的方法切换回主视图时,它很容易。但是当我把 uipopover 放在两者之间时,问题就出现了。因此,例如,当我从主视图按下按钮时,在它切换之前,弹出框出现在弹出框内的 rect 按钮,并且在我按下按钮后,出现了第二个视图。这是问题开始的地方。在第二个视图中,当我试图将设备从横向向右放置到横向左侧时,第二个视图只是卡住了,但主视图(在背景中)确实旋转到了指定方向。这是我在两个实现文件中使用的代码:

#import "landscapeViewController.h"
#import "popOver.h"

@interface landscapeViewController ()


@end

@implementation landscapeViewController
@synthesize myPopover;



-(IBAction)showPop:(id)sender {
    popOver *popover = [[popOver alloc] init];
    UIPopoverController *pop1 = [[UIPopoverController alloc] initWithContentViewController:popover];
    self.myPopover = pop1;
    [pop1 setDelegate:self];
    [pop1 setPopoverContentSize:CGSizeMake(300,200)];   
    [self.myPopover presentPopoverFromRect:[popbtn bounds] inView:popbtn permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

}




- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

@end

这是切换视图的代码:

-(IBAction)switchView:(id)sender {

    secondView *second = [[secondView alloc] initWithNibName:nil bundle:nil];
    second.modalTransitionStyle = UIModalTransitionStyleCoverVertical;
    [self presentModalViewController:second animated:YES];
    [self dismissModalViewControllerAnimated:YES];


}

并从第二个视图切换回来:

-(IBAction)switchBack:(id)sender {
    landscapeViewController *land = [[landscapeViewController alloc] initWithNibName:nil bundle:nil];
    land.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
    [self presentModalViewController:land animated:YES];


}

我希望有人可以帮助我。先谢谢了。再次为糟糕的英语感到抱歉。

4

0 回答 0