使用 IBuilder 进行振动检测或不使用 IBuilder 加载视图
我正在编写一些需要检测震动的应用程序(假设游戏 - 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当我将视图插座与控制器连接起来时,它开始工作......如下:
while I have connected view outlet in view with controller it started to work... with this: