加载新视图

发布于 2024-10-06 18:41:41 字数 790 浏览 0 评论 0原文

好吧,我确信我在某个地方错过了这个,但我想我需要其他人来解决这个问题,因为我已经在这个问题上绕了一段时间了。

我的情况确实很简单。

我有两个文件 TapView.m TapView.h,

当AppController.m调用showTapView方法时加载。

    -(void) showTapView {
[tapViewController resetAllStates:self];
[navigationController pushViewController animated:YES];
[tapViewController prepareTapView];
[[UIAccelerometer sharedAccelerometer] setDelegate:tapViewController];
}

现在一切都进展顺利,并且可以愉快地加载 TapView。这不是真正的问题,但我不喜欢以编程方式构建接口,我希望能够做的是更改此方法,以便加载它调用的以编程方式创建的视图基于 XIB 的视图,为了便于讨论,我们将其称为 LazyView

现在,如果这样做是一件大事,我很高兴,并且可以保留它的编程倾向,只是让它通过 Interface Builder 工作将在未来进一步扩展应用程序时对我有很大帮助:)


如果有人想知道顺便说一句,我使用开源项目中的一些示例构建了该应用程序,该应用程序现在没有太多相似之处,但它来自 Remotepad - 非常感谢这些人发布了源代码,它帮助我获得了我的绕着卓悦走下去没有尽头。

Ok so I'm sure I'm missing this somewhere but I think I need someone else to bounce this off as I've been going around in circles on this for some time.

My situation is quite straight forward really.

I've got two files
TapView.m
TapView.h

which are loaded when the AppController.m calls the showTapView method.

    -(void) showTapView {
[tapViewController resetAllStates:self];
[navigationController pushViewController animated:YES];
[tapViewController prepareTapView];
[[UIAccelerometer sharedAccelerometer] setDelegate:tapViewController];
}

Now this all works swell and loads TapView in happily enough. It's not really an issue, but I don't like building interfaces progmatically, what I'd love to be able to do is to change this method so that instead of loading a progmatically created view it calls on a XIB based view, let's call it LazyView for the sake of arguments.

Now if it's a big thing to do this I'm happy as is and can leave it progmatically inclined, it's just that having it working through Interface Builder will help me significantly in the future as I expand the application further :)


If anyone's wondering by the way, I've built the app using some samples from open source projects, the app doesn't bear much resemblance these days but it was from Remotepad - many thanks to the guys for the release of the source, it helped me get my head around Bonjour no end.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

热血少△年 2024-10-13 18:41:41

听起来您正在寻找 initWithNibName 方法来从 Nib 加载视图控制器。

UIViewController* controller = [[LazyViewController alloc] initWithNibName:@"LazyViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
[controller release];

Sounds like you are looking for the initWithNibName method to load a view controller from a Nib.

UIViewController* controller = [[LazyViewController alloc] initWithNibName:@"LazyViewController" bundle:nil];
[self.navigationController pushViewController:controller animated:YES];
[controller release];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文