0

我在 IB 中创建了这个对话框: 对话

我通过以下方式设置了一个segue: 转场

这就是我配置 ViewController 的方式: 视图控制器

这就是我配置视图指标的方式: 查看指标

这是我在 iOS 模拟器中得到的: 在此处输入图像描述

所以:有人能告诉我为什么吗,我怎么能以他们视觉上想要的方式得到这个,我在哪里可以找到一个非常好的界面构建器教程?

提前致谢。

4

1 回答 1

2

“表单”模态演示样式始终使用相同大小的容器,并且您不能覆盖它。使用 iOS 7 或更高版本,您可以定义自定义模式演示样式来完成您想要的,或搜索 GitHub。

这是一个具有自定义大小的 iOS 6 兼容实现。

/** Created in answer to mirx's question at http://stackoverflow.com/questions/18803961/why-are-the-dimensions-of-my-modal-view-different-from-what-i-expect/18805374?noredirect=1#comment27741546_18805374 */

@interface AHPresentingViewController : UIViewController
@property (nonatomic, weak) UIView *presentedBackgroundView;
@property (nonatomic, weak) UIViewController *formController;
@end

@implementation AHPresentingViewController

-(void)viewDidAppear:(BOOL)animated {
    [super viewDidAppear:animated];
    UITableViewController *table = [UITableViewController new];
    table.title = @"Form";
    UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:table];
    table.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(dismissPresentedForm:)];
    [self presentForm:nav size:CGSizeMake(320, 240)];
}
-(void)presentForm:(UIViewController *)formVC size:(CGSize)size {
    if(self.formController) return;
    NSLog(@"Form view: %@",formVC.view);
    UIView *background;
    self.presentedBackgroundView = background = [[UIView alloc] initWithFrame:self.view.bounds];
    background.opaque = NO;
    background.backgroundColor = [UIColor blackColor];
    background.alpha = 0;
    [self.view addSubview:background];
    formVC.view.frame = (CGRect){CGPointZero, size};
    formVC.view.center = CGPointMake(CGRectGetWidth(self.view.bounds) / 2., CGRectGetHeight(self.view.bounds) + CGRectGetHeight(formVC.view.bounds));
    [self addChildViewController:formVC];
    self.formController = formVC;
    [self.view addSubview:formVC.view];

    [UIView animateWithDuration:0.5 animations:^{
        background.alpha = 0.4;
        formVC.view.center = CGPointMake(self.view.bounds.size.width / 2., self.view.bounds.size.height / 2.);
    }];
}
-(void)dismissPresentedForm:(id)sender {
    if(!self.formController) return;
    [UIView animateWithDuration:0.5 animations:^{
        self.presentedBackgroundView.alpha = 0;
        self.formController.view.center = CGPointMake(CGRectGetWidth(self.view.bounds) / 2., CGRectGetHeight(self.view.bounds) + CGRectGetHeight(self.formController.view.bounds));
    } completion:^(BOOL finished) {
        [self.presentedBackgroundView removeFromSuperview];
        [self.formController.view removeFromSuperview];
        [self.formController removeFromParentViewController];
    }];
}
@end
于 2013-09-14T19:06:21.470 回答