代码之家  ›  专栏  ›  技术社区  ›  Duck

iphone-presentModalViewController可以全屏显示吗?

  •  3
  • Duck  · 技术社区  · 14 年前

    UIViewController *myWindow = [[UIViewController alloc] init];
    CGRect myFrame = CGRectMake(0.0f, 0.0f, 115.0f, 120.0f);
    myWindow.view.frame = myFrame;
    
    [self presentModalViewController:myWindow animated:YES];
    

    有什么办法我可以不全屏显示在一个特定的大小?

    2 回复  |  直到 14 年前
        1
  •  3
  •   Joshua Weinberg    14 年前

    没有“标准”的方法可以做到这一点。

    我用假币伪造的 UIActionSheet

    sheet = [[UIActionSheet alloc] initWithTitle:nil delegate:nil cancelButtonTitle:nil destructiveButtonTitle:nil otherButtonTitles:nil];
    sheet.actionSheetStyle = UIActionSheetStyleBlackTranslucent;
    
    UIViewController *modalController = [[UIViewController alloc] initWithNibName:@"SomeNib" bundle:nil];
    
    sheet.autoresizesSubviews = NO;
    [sheet addSubview:modalController.view];
    [sheet showInView:self.view];
    [UIView beginAnimations:nil context:nil];
    [sheet setBounds:CGRectMake(0, 0, 320, 728)];
    [UIView commitAnimations];
    

    这里的明显缺点是不触发常规视图控制器事件( viewWillAppear: , viewDidAppear: 等)

        2
  •  2
  •   deanWombourne    14 年前

    不容易,但你能做到 似乎 较小:)

    只需在您的xib全屏上创建根视图,但背景清晰透明。然后,在里面,你的'真正的'用户界面对象任何大小你想要的。