I am wondering if i can show all leaderboards instead of going to a specific leaderboard in gamecenter. I have my game now that whenever you hit the leaderboard button it goes to my default, but I was wondering if there was a way to show all on the button click.
To view all of the leaderboards use this:
- (void) presentLeaderboards
{
GKGameCenterViewController* gameCenterController = [[GKGameCenterViewController alloc] init];
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
gameCenterController.gameCenterDelegate = self;
[self presentViewController:gameCenterController animated:YES completion:nil];
}
The key difference here is that in my code I have
gameCenterController.viewState = GKGameCenterViewControllerStateLeaderboards;
while you would have
gameCenterController.viewState = GKGameCenterViewControllerStateDefault;
Related
I have a plus button in my primary view controller of a UISplitViewController and i want to present something modally in my detail view, just like apple does when adding a new contact in address book in iPad. I have tried everything but nothing. I managed to do it but when i am trying to embed my presented view controller into a UINavigation controller then my presented controller covers the full screen. Any suggestions? Here is my code:
UINavigationController *navController = [self.splitViewController.viewControllers lastObject];
DetailTableViewController *controller = (DetailTableViewController *)navController.topViewController;
controller.definesPresentationContext = YES;
controller.providesPresentationContextTransitionStyle = YES;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:#"Main" bundle:nil];
EditTableViewController *etvc = (EditTableViewController *)[storyboard instantiateViewControllerWithIdentifier:#"EditTableViewController"];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:etvc];
etvc.patient = patient;
if (IDIOM == IPAD)
{
etvc.modalPresentationStyle = UIModalPresentationCurrentContext;
[controller presentViewController:nav animated:YES completion:nil];
} else {
[self presentViewController:nav animated:YES completion:nil];
}
I just successfully solved this problem by creating a custom segue whose implementation is:
- (void)perform
{
UIViewController *ctrl = self.sourceViewController;
UIViewController *dest = self.destinationViewController;
dest.modalPresentationStyle = UIModalPresentationCurrentContext;
[ctrl presentViewController:dest animated:YES completion:nil];
}
I'm seeing the behavior I want by invoking this segue from my detail view controller on the modal view I want to overlay it.
I think where your code is going haywire is here:
etvc.modalPresentationStyle = UIModalPresentationCurrentContext;
I think it should be:
nav.modalPresentationStyle = UIModalPresentationCurrentContext;
Though I haven't tested it.
Note that the Apple docs suggest that modalPresentationStyle is ignored on the iPhone (or on "horizontally compact devices"), so your "IS_IPAD" check may be redundant.
Hope this helps!
This is my First Sprite game, and for some reason the only difficult I've been run to is the admob integration.
This is my ViewDidLoad
- (void)viewDidLoad
{
[super viewDidLoad];
// showing for the first time my AdMob Interstitial
[self showAdmobFullscreen];
// Configure the view.
SKView * skView = (SKView *)self.view;
SKScene *mc = [GameScene01 sceneWithSize:skView.bounds.size];
mc.scaleMode = SKSceneScaleModeAspectFill;
[skView presentScene:mc];
}
and this is my Admob Settings:
-(void)showAdmobFullscreen{
NSLog(#" showAdmoBFullScreenCalled");
// self.interstitial_ = [[GADInterstitial alloc] init];
// self.interstitial.delegate = self;
// self.interstitial.adUnitID = ADMOB_FULLSCREEN_ID;
// [self.interstitial loadRequest:[self adMobrequest]];
interstitial_ = [[GADInterstitial alloc]init];
interstitial_.delegate = self;
interstitial_.adUnitID = #"ca-app-pub-1032576214759203/773434443";
[interstitial_ loadRequest:[self adMobrequest]];
}
- (GADRequest *)adMobrequest {
NSLog(#"requestHasBeenCalled");
GADRequest *request = [GADRequest request];
request.testDevices = #[
// TODO: Add your device/simulator test identifiers here. Your device identifier is printed to
// the console when the app is launched.
//#"9481d65c607d68c867a51229a3c61340"
];
return request;
}
So Far So Good, The admob is fire when the game load. now I want to fire it every time when the user lose in the game.
Right now the whole game run into my Sprite files, and what I tried todo is to call the 'showAdmobFullscreen' every time there's a GameOver
So in my Sprite.m file, I have a method called GameOver, I've added those lines :
-(void)GameOver
{
//Trying to make Admob shows whenever User loses a game
MyMainViewController *spVc = [[MyMainViewController alloc]init];
[spVc showAdmobFullscreen];
I can see the logs of my Admob are being called but no ads are showing up.
any suggestion will be appreciated .
Instead of
MyMainViewController *spVc = [[MyMainViewController alloc]init];
[spVc showAdmobFullscreen];
Try this
[self showAdmobFullscreen];
I am working on small application and i am new to osx programming, i have searched all over but I didnt find how to show custom about window.
In my application i have 3 controllers one for log in and then i switch to other but third one is About but I dont know how to change when someone click on about menu, i have come to know that orderfrontstandardaboutpanel called but how i gonna use it to show my view? this is my
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
_accountDetails = [[NSDictionary alloc] init];
self.loginViewController = [[MTLoginViewController alloc] initWithNibName:#"MTLoginViewController" bundle:nil];
self.loginViewController.delegate = self;
// 2. Add the view controller to the Window's content view
[self.window.contentView addSubview:self.loginViewController.view];
// [self setUIWindowsFrame:self.loginViewController.view.frame];
self.loginViewController.view.frame = ((NSView*)self.window.contentView).bounds;
}
I am working on an app in which there are five UITextFields in one view controller, the user can fill the text fields they want and when they press a UIButton they'll get a randomized answer on a second view controller via a UILabel.
I got it to work so far, but let's say the user only fills the first two UITextFields and the random answer they get is from a blank, unfilled UITextField.
My question is: how do I make work so that the unfilled UITextFields are not part of the random count? Is this possible?
Here's the code:
FifthViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.choice1.delegate = self;
self.choice2.delegate = self;
self.choice3.delegate = self;
self.choice4.delegate = self;
self.choice5.delegate = self;
}
- (IBAction)choicebutton:(id)sender {
SixthViewController *SVC = [self.storyboard instantiateViewControllerWithIdentifier:#"SixthViewController"];
SVC.stringFromChoice1 = self.choice1.text;
SVC.stringFromChoice2 = self.choice2.text;
SVC.stringFromChoice3 = self.choice3.text;
SVC.stringFromChoice4 = self.choice4.text;
SVC.stringFromChoice5 = self.choice5.text;
[self presentViewController:SVC animated:YES completion:nil];
}
SixthViewController.m
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
self.choiceAnswers = #[self.stringFromChoice1,
self.stringFromChoice2,
self.stringFromChoice3,
self.stringFromChoice4,
self.stringFromChoice5];
int index = arc4random() % [self.choiceAnswers count];
self.choiceanswer.text = self.choiceAnswers[index];
}
Thanks!
SixthViewController
You can check and see if a string is empty before adding it to self.choiceAnswers:
if(![self.stringFromChoice1 isEqualToString#""]);
{
[self.choiceAnswers addObject:self.stringFromChoice1];
}
Make sure that you are using an NSMutable array for self.choiceAnswers.
When I have switched to another view (After returning from taking a picture or after switching to a view to select stuff in table) the ipad keyboard appears at the wrong position.
When I select a text field, I see this on my Ipad and on the simulator. (can't post images yet). If I turn my ipad (so that it aligns horizontal) and rotate back the keyboard is back normal.
https://devforums.apple.com/servlet/JiveServlet/showImage/2-701040-19966/Screen+Shot+2012-07-20+at+16.36.20.png
My code to switch to the camera for taking a picture...
- (IBAction)getCameraPicture:(id)sender
{
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.title = #"CameraPicture";
[self presentModalViewController:picker animated:YES];
}
My code to switch to a view with a table in it :
[self presentModalViewController:viewControllerSpanoTechProducts animated:YES];
code for returning after selecting stuff :
[self dismissModalViewControllerAnimated:YES];
how my app works: you have a main screen with buttons and textfield to fill in a form. when you push a button to select a product I switch to another viewcontroller with a table where you can select a product and a button 'done'. If you click the 'done' button I switch back to the original view.. hope this helps?
I'm just started with iOS.. Any help is appriciated!
At the time of switch user this code:
[yourTextFieldObject resignFirstResponder];
This might work.