开发者

Shake detection with using IBuilder or Load View without IBuilder [duplicate]

开发者 https://www.devze.com 2023-02-04 13:49 出处:网络
This question already has answers here: iPhone Shake event not properly working (2 answers) Closed 2 years ago.
This question already has answers here: iPhone Shake event not properly working (2 answers) Closed 2 years ago.

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开发者_StackOverflow中文版 for help in advance. Mariusz


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

[self becomeFirstResponder]
0

精彩评论

暂无评论...
验证码 换一张
取 消