iPhone 模态视图比屏幕小 [英] iPhone Modal View Smaller that the screen

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

问题描述

我正在尝试做一些不应该那么复杂的事情,但我想不通.我有一个 UIViewController 显示一个 UITableView.我想在用户按下一行时显示一个上下文菜单.我希望这是一个带有标签和按钮的半透明视图.我可以使用 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 设置为 0.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.

贡索

推荐答案

我正在编写类似的代码.我的方法包括.....

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

  1. 不使用dismissModalViewControllerAnimated 和presentModalViewController:animated.

  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 包含一个经过 photoshop 处理的图像,该图像具有圆角并且背景设置为透明.此图像视图用作容器.

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 模态视图比屏幕小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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