【问题标题】:UIView transition and animationUIView 过渡和动画
【发布时间】:2010-03-15 21:22:47
【问题描述】:

我了解模态视图会覆盖整个屏幕。但我真的想要一个只覆盖一半屏幕的视图,就像键盘一样。所以,请告诉我为什么这不起作用

MyController *controller = [[MyController alloc] initWithNibName:@"MyView" bundle:nil];
CGRect frame = CGRectMake(0,44,768,264);
[controller view].frame = frame;
contoller.delegate = self;
[[self view] addSubView:[controller view]];
[controller release];

我正在尝试将一个子视图添加到我的当前视图并使其出现在键盘出现的位置。

它抛出一个 BAD ACCESS 异常

【问题讨论】:

  • 您是否在 Interface Builder 中将视图连接到其控制器?

标签: objective-c uiview uiviewcontroller model-view-controller


【解决方案1】:

在我的代码(上面)中,我使用了一个自定义 UIViewController 和它自己的视图 [在 IB 上设置为 UIView]。我无法通过为视图控制器的视图设置框架来使其工作。

所以我添加了一个没有 Nib 文件的自定义 UIView,并在 initWithFrame 上添加了所有控件(按钮、文本字段)。

MyCustomView = [[MyCustomView] alloc] initWithFrame:frame delegate:self];
[self.view addSubView:MyCustomView];

感谢您的评论,雅各布。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-06-15
    • 2012-01-31
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多