I am currently working on an app with augmented reality. I chose to use the ARToolKit library (available on github).
I have a little problem to integrate my view in my project.
The problem is that I can not see my navigationbar when UIImagePickerController is launched
AugmentedRealityController.m
- (Void) displayAr
[RootViewController presentModalViewController: [self cameraController] animated: NO];
[DisplayView setFrames: [[[self cameraController] view] bounds]];
)
I guess the problem come from here. I can not view the UIImagePickerController that if I go through presentModalViewController.
By making a pushviewcontroller from my navigation controller it does not work either (after read documentation).
After some research on documentation should be implemented by the delegate access UIImagePickerController and UINavigationController. Even with that it does not work either (sniff).
I picked this version here: http://github.com/nielswh/iPhone-AR-Toolkit/commit/681165d383ab590d03a0daaf761bc25b59d1acd6
I adapted a few things so that his running iOS 4.1 (actually this version is 3.1.3).
I do not know if there have been changes regarding the use of UIImagePickerController since.
If anyone has an idea, help or something. After half a day searching the internet I try many things in vain
Related
I've posted this question elsewhere, but as SO is such a great community I'm doing so here as well.
First up, I'm using Cocos2D 2.0-gles20 to put a multiplayer/team oriented game together.
I've been integrating GameKitHelper into the app. To date it's been working just fine on my iPhone4 and iPad2 and in the Simulator, but now when I try to use it on an iPod Touch 4th I'm getting assertions in [CCDirectorIOS startAnimation] because the app is getting a viewWillAppear when it shouldn't and no call to viewDidDisappear when it should.
The reason this matters is that these methods on the CCDirectorIOS class cause Cocos2D to start/stop animation whilst another UIKit view is in front. This is something that I've managed myself with Cocos2D-0.99 but with 2.0 it is handled nicely within the director so that each app doesn't have to handle it specifically.
The GameKitHelper class has the following methods for pushing a GKMatchmakerViewController onto the screen:
-(void) showMatchmakerWithInvite:(GKInvite*)invite
{
GKMatchmakerViewController* inviteVC = [[[GKMatchmakerViewController alloc] initWithInvite:invite] autorelease];
if (inviteVC != nil)
{
inviteVC.matchmakerDelegate = self;
[self presentViewController:inviteVC];
}
}
-(UIViewController*) getRootViewController
{
return [CCDirector sharedDirector];
}
-(void) presentViewController:(UIViewController*)vc
{
UIViewController* rootVC = [self getRootViewController];
[rootVC presentModalViewController:vc animated:YES];
}
-(void) dismissModalViewController
{
UIViewController* rootVC = [self getRootViewController];
[rootVC dismissModalViewControllerAnimated:YES];
}
When I call showMatchmakerWithInvite, on the iPhone4, etc I see a call to viewDidDisappear: on the CCDirectorIOS object which stops animation. This is fine. When the GK view is gone, I see a call to viewWillAppear which restarts the animation. Sweet.
On the iPod Touch however, running exactly the same project, the call to viewDidDisappear is not made, but a call to viewWillAppear is, before the GK view has gone.
I can't fathom why there would be a difference. All devices are running iOS 5.1.1.
It's almost as if the behaviour of UIKit is different on the iPod Touch, but I find that hard to believe. My other thought was that I was looking at a timing issue, but I put some code in to allow the app to keep running even with the problem, but the call to viewDidDisappear never happened.
I can work around this I think by managing the start/stop of animation myself, but I would have preferred not to customise the Cocos2D code.
Does anyone have any ideas?
Thanks
Well, being the impatient person I am, rather than leave it to others and work on something else, I nutted it out.
I turns out that the iPod Touch devices in question had multi player games disabled in the restrictions app. This seems to cause the GK view to not show "properly" and as a result the events like viewDidDisappear: and viewWillAppear: don't occur the way I was expecting.
So I've been able to revert all of my tweaks and instrumentation in the Cocos2D code, and simply apply a correction to the GameKitHelper class to ensure that if features such as multi-player are disabled, the player isn't able to request them.
Do I need iPhone developer certificate and the app available on the app store in order to implement game center.
Is it easy to implement game center leader boards into your game and if so any tutorials on doing so. I have a score counter already ,but not sure how I would add it into game center.
Any good tutorials on implementing game center into cocos2d and if so may I see a link (yes I have seen some tutorials ,but I want to be recommended a good tutorial).
You need an iPhone developer account to test and implement game center. You don't need to have an app on the App Store you can just test it on an unreleased project. I suggest you read the following tutorial, which explains everything about leaderboards pretty clearly:
Leaderboards Tutorial
Yes - but you would anyway to test on a device. And no, you have a 'sandboxed' version of Game Centre where games not on the app store/ development builds are tested.
Implementing leader-boards difficulty depends on what version of cocos2D you are using. From experience version 1 is a little more challenging then 2. Here is some code on how I have implemented it;
- (void)showLeaderboardForCategory:(NSString *)category
{
// Create leaderboard view w/ default Game Center style
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
// If view controller was successfully created...
if (leaderboardController != nil)
{
// Leaderboard config
leaderboardController.leaderboardDelegate = self; // The leaderboard view controller will send messages to this object
leaderboardController.category = category; // Set category here
leaderboardController.timeScope = GKLeaderboardTimeScopeAllTime;
// Create an additional UIViewController to attach the GKLeaderboardViewController to
myViewController = [[UIViewController alloc] init];
[[[CCDirector sharedDirector] openGLView] addSubview:myViewController.view];
// Tell UIViewController to present the leaderboard
[myViewController presentModalViewController:leaderboardController animated:YES];
}
}
- (void)leaderboardViewControllerDidFinish:(GKLeaderboardViewController *)leaderboardController
{
[myViewController dismissModalViewControllerAnimated:YES];
myViewController.view = nil;
[myViewController release];
}
(Credit to the SO post that I originally used though - Leaderboard doesn't add in the screen cocos2d)
The Rod Strougo and Ray Wenderlich book "Learning Cocos2d" (2012) gives some good sample code for implementing game center leaderboards and achievements. Also "Learn cocos2d Game Development with iOS5" by Itterheim and Loew gives good examples too.
I followed the Strougo examples and it worked more-or-less the first time. But something people get stuck on (I did) is how to test. If you don't do it right it will seem like it isn't working when it actually is. It sounds like you haven't gotten started with GC yet so I won't try to explain what to do. Just be aware when the time comes to test that there is a procedure you need to follow that isn't completely obvious.
hey i am beginner in iphone application development.
i developed simple application in iphone but i also required it in ipad so for that i start coding for ipad but i didn`t get navigation properly in ipad code through
[self presentModalViewController:navController animated:YES];
[self.navigationController presentModalViewController:navController animated:YES];
for that i use addsubView Method but it didnt get its navigation controller from viewdidload method.
and please tell me how much this type of diffrences b\w iphone and ipad applications.....
if thier is any tutorial on ipad appication than tell me..........
Main difference between iPhone and iPad app is UI design, code behind the logic is same if you are using same components, there are some of the UI elements which are only iPad only like splitview, popup view as you start using these your code behind also changes.
you will get many samples on apple developers.
controller.modalTransitionStyle = UIViewAnimationTransitionFlipFromLeft;
[self presentModalViewController:controller animated:YES];
Is there any way to make it flipping with a thick border/side? (like iBooks app, when you're switching between books view and the books store)
The code or API Apple used for this transition is not publicly available, so you would need to implement your own custom OpenGL transition. Lucky for you, someone else had the same idea and implemented a helper class that includes a thick-border flip transition: EPGLTransitionView. If this is not to your liking, check out this SO thread on custom view transitions.
EPGLTransitionView uses OpenGL. Try this project instead, fully done in CoreAnimation:
https://github.com/devindoty/iBooks-Flip-Animation
Issue summary
Changing the orientation of an iPad device or simulator while playing a video using MPMoviePlayerViewController results in an inconsistent rotation state upon dismissal of the video player. This is a known bug in iPad SDK 3.2, documented at http://www.openradar.me/8012810
Sample project
I have prepared a minimal sample project using the View-based Application template from Xcode 3.2.2, using the following code to launch the player
NSURL *movieUrl = [NSURL URLWithString:#"http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"];
MPMoviePlayerViewController *player = [[MPMoviePlayerViewController alloc] initWithContentURL:movieUrl];
[self presentMoviePlayerViewControllerAnimated:player];
[player release];
The code is available on GitHub at http://github.com/adamalex/FullScreenMovie or direct download using http://github.com/adamalex/FullScreenMovie/zipball/master
Steps to reproduce
Obtain the project using the information above
Launch the project with the iPad simulator or device
Tap the button to begin playing the video
Rotate the iPad by 90 degrees
Dismiss the video
Note the UIStatusBar is out of sync with the application UI
Objective
I have contacted Apple and they have confirmed this is a bug that is being investigated. I would like to discuss temporary workarounds that use public APIs safe for submission to the App Store. I am going to open a developer support case with Apple as well and will report back with my own progress.
Successful response from Apple Developer Technical Support!
This is a known bug and a we're received a number of duplicate bug reports and so iOS engineering is aware of the issue and we do have a temporary workaround as suggested by iOS engineering.
You will need to implement this in the view controller which presents the movie player.
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation {
[super didRotateFromInterfaceOrientation:fromInterfaceOrientation];
[self performSelector:#selector(fixStatusBar) withObject:nil afterDelay:0];
}
- (void)fixStatusBar {
[[UIApplication sharedApplication] setStatusBarOrientation:[self interfaceOrientation] animated:NO];
}
While this is somewhat ugly, it should fix the issue for now. It would be recommended to remove this code once the bug is fixed in the system.
This took care of the issue completely for me, and you can revisit http://github.com/adamalex/FullScreenMovie for the code with the fix applied.
This also solves an iPhone/iPodTouch rotation issue that I was struggling with. I am developing a universal app in which each view displays a different image depending on whether the device is in portrait or landscape orientation. Buttons are used to navigate between views.
If the app is running on the device and a portrait view is rotated to landscape, my image switching takes place. If the device is then placed flat on a table top and the button is tapped to display the next view, the view appears in landscape but shows the portrait image instead. I solved the problem by forcing a portrait view to appear by detecting for face up and down, but Apple's code solved this problem (as well as the similar movie problem I was also experiencing).
Many thanks for reporting the bug - I assumed it was just my bad coding...