使用 IBuilder 进行振动检测或不使用 IBuilder 加载视图

发布于 2024-10-11 01:20:58 字数 1143 浏览 7 评论 0原文

我正在编写一些需要检测震动的应用程序(假设游戏 - 1 视图没有可可控件)。 作为 IOS 的初学者,已经开始使用默认的 openGL 模板(新模板)。应用程序有效。

我决定添加奶昔。 “motionBegan”不适用于“EAGLEview”,所以我创建了视图控制器。触摸有效,但“motionBegan”仍然无效。 (与“viewDidAppear”相同)

我认为 IBuilder 文件以某种方式与它重叠。 所以我决定退出我的 IBuilder 文件并继续前进。

我现在拥有的是:

main.m

int retVal = UIApplicationMain(argc, argv, nil, @"SimplePianoAppDelegate");

SimplePianoAppDelegate.m

window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[window setUserInteractionEnabled:YES];
[window setMultipleTouchEnabled:YES];


viewController = [[InputControler alloc] init];
glView=[[EAGLView alloc] initWithFrame:window.bounds];
glView.hidden=NO;
viewController.view=glView;

[window bringSubviewToFront:glView];
[window addSubview:viewController.view];
[window makeKeyAndVisible];

[glView setMultipleTouchEnabled:YES];
[glView performSelectorOnMainThread:@selector(mainAppLoop) withObject:nil waitUntilDone:NO]; 

使用此代码触摸和动作有效,但我没有看到任何东西。 (只是白屏):(

我确信上面的某些行是不必要的,但我正在尝试所有可能的选项。奇怪的是,无论我是否创建 glView , viewcontroller 中的“loadView”都不会被调用。 提前感谢您的帮助。 马里尤什

I am writing some application (let's say game - 1 view no cocoa controls) which needs to detect shakes.
As beginner with IOS have started with default openGL template (new one). Application works.

I have decided to add shakes. "motionBegan" don't work on "EAGLEview", so I have created view controller. Touches worked but "motionBegan" still not worked. (same like "viewDidAppear")

I thought that somehow IBuilder file is overlapping it.
So I have decided to resign from my IBuilder file and move forward without.

What I have now is:

main.m

int retVal = UIApplicationMain(argc, argv, nil, @"SimplePianoAppDelegate");

SimplePianoAppDelegate.m

window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
[window setUserInteractionEnabled:YES];
[window setMultipleTouchEnabled:YES];


viewController = [[InputControler alloc] init];
glView=[[EAGLView alloc] initWithFrame:window.bounds];
glView.hidden=NO;
viewController.view=glView;

[window bringSubviewToFront:glView];
[window addSubview:viewController.view];
[window makeKeyAndVisible];

[glView setMultipleTouchEnabled:YES];
[glView performSelectorOnMainThread:@selector(mainAppLoop) withObject:nil waitUntilDone:NO]; 

With this code touches and motions worked but I don't see anything. (just white screen) :(

I am sure that some of the lines above are not necessary, but I am trying all possible options. What is strange is that no matter if I create my glView or not "loadView" in viewcontroller is not called.
Thank you for help in advance.
Mariusz

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

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

发布评论

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

评论(1

山人契 2024-10-18 01:20:58

当我将视图插座与控制器连接起来时,它开始工作......如下:

[self becomeFirstResponder]

while I have connected view outlet in view with controller it started to work... with this:

[self becomeFirstResponder]
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文