iPhone Modal View屏幕较小 [英] iPhone Modal View Smaller that the screen

查看:125
本文介绍了iPhone Modal View屏幕较小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试做一些不应该那么复杂的事情,但我无法弄明白。
我有一个显示UITableView的UIViewController。我想在用户按行时显示上下文菜单。我希望这是一个带有标签和按钮的半透明视图。
我可以使用AlertView,但我希望完全控制标签和按钮的格式,并希望使用Interface Builder。

I'm trying to do something that shouldn't be that complicated, but I can't figure it out. I have a UIViewController displaying a UITableView. I want to present a context menu when the user press on a row. I want this to be a semi-transparent view with labels and buttons. I could use an AlertView, but I want full control on the format of the labels and buttons and will like to use Interface Builder.

所以我创建了我的小视图250x290,将alpha设置为.75并创建一个带有出口的视图控制器来处理不同的用户事件。

So I created my small view 250x290, set the alpha to .75 and create a view controller with the outlets to handle the different user events.

现在我想呈现它。
如果我使用presentModalViewController两个(不需要的)事情发生
1)视图覆盖了所有屏幕(但状态栏)。
2)它是半透明的,但我看到背后它不是父视图而是应用程序根视图。

Now I want to present it. If I use presentModalViewController two (undesired) things happen 1) the view covers all of the screen (but the status bar). 2) It is semi-transparent, but what I see "behind" it its not the parent view but the applications root view.

我试过添加它作为子视图,但没有任何反应,所以我没做正确的事情:

Ive tried adding it as a subview, but nothing happens, so Im not doing something right:

RestaurantContextVC* modalViewController = [[[RestaurantContextVC alloc] initWithNibName:@"RestaurantContextView" bundle:nil] autorelease];
[self.view addSubview:modalViewController.view];

有可能做我想做的事吗?
提前致谢。

Is it possible to do what I want? Thanks in advance.

Gonso

推荐答案

我编码类似的东西。我的方法包括.....

I'm coding similar thing. My approach include.....


  1. 不使用dismissModalViewControllerAnimated和presentModalViewController:动画。

  1. Not using dismissModalViewControllerAnimated and presentModalViewController:animated.

在IB中设计自定义的全尺寸视图。在其viewDidLoad消息体中,将背景颜色设置为clearColor,以便控制器未覆盖的视图上的空间是透明的。

Design a customized full sized view in IB. In its viewDidLoad message body, set the background color to clearColor, so that space on the view not covered by controllers are transparent.

我将UIImageView放在浮动视图的控制器。 UIImageView包含一个photoshoped图像,它有圆角,背景设置为透明。此图像视图用作容器。

I put a UIImageView under the controllers of the floating view. The UIImageView contains a photoshoped image, which has rounded corners and the background is set to transparent. This image view serves as the container.

我使用CoreAnimation以模态视图样式显示/关闭浮动视图:(FloatingViewController.m)

I uses CoreAnimation to present/dismiss the floating view in the modal view style: (the FloatingViewController.m)

-  (void)viewDidLoad
{
    [super viewDidLoad];
    [self.view setBackgroundColor:[UIColor clearColor]];

    [UIView beginAnimations:nil context:nil];
    [self.view setFrame:CGRectMake(0, 480, 320, 480)];

    [UIView setAnimationDuration:0.75f];
    [self.view setFrame:CGRectMake(0, 0, 320, 480)];
    [UIView commitAnimations];
}


这篇关于iPhone Modal View屏幕较小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆