GKLeaderboard in SpriteKit? - sprite-kit

How can I use a GKLeaderboard in SpriteKit ?
When I try to present a Leaderboard a got this issue.
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIView setShowsFPS:]: unrecognized selector sent to instance 0x17017fb00'
First throw call stack:
(0x18df0ef50 0x19a4181fc 0x18df13c04 0x18df11930 0x18de315dc 0x100069e00 0x190ed8670 0x190ed83f4 0x190fccd08 0x18df13700 0x18de2ceec 0x1911d5ee4 0x18ed278dc 0x18df13700 0x18de2ceec 0x19a9f0014 0x19a9effd4 0x19a9f31dc 0x18decec2c 0x18deccf6c 0x18de0dc20 0x193af5c0c 0x190f3efdc 0x1000dcb34 0x19aa0baa0)
libc++abi.dylib: terminating with uncaught exception of type NSException**
My Method to show the leaderboard:
-(void) showLeader
{
GKLeaderboardViewController *leaderboardController = [[GKLeaderboardViewController alloc] init];
if (leaderboardController != nil)
{
leaderboardController.leaderboardDelegate = self;
[self presentModalViewController:leaderboardController animated:YES];
}
}
Thanks in advance!

presentModalViewController was deprecated in iOS 6. GKLeaderbardViewController is deprecated in iOS 7.
You an refer to this:
What should I use instead of deprecated GKLeaderboardViewController in iOS7?

Related

How to create raw image in iOS?

I want to create raw image using UIImagePickerController. I'm doing like this but getting crash on this line uiipc.mediaTypes=#[(NSString *)kUTTypeRawImage]; crash report says:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'No available types for source 1'.
Code here
UIImagePickerController *uiipc = [[UIImagePickerController alloc] init];
uiipc.delegate=self;
uiipc.mediaTypes=[UIImagePickerController availableMediaTypesForSourceType:uiipc.sourceType];
// uiipc.mediaTypes = #[(NSString *)kUTTypeImage];
uiipc.mediaTypes=#[(NSString *)kUTTypeRawImage];// Getting crash here
uiipc.sourceType = UIImagePickerControllerSourceTypeCamera;
uiipc.allowsEditing = YES;
_imgPickViewController=uiipc;
[self presentViewController:_imgPickViewController animated:NO completion:nil];

Exception while setting property in subclass of MKMapView

I got a strange error. After I installed my test app in release mode I got an error:
[SomeMapView setRotateEnabled:]: unrecognized selector sent to instance 0x1c58ac40
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[SomeMapView setRotateEnabled:]: unrecognized selector sent to instance 0x1c58ac40'
The Mapview was initialized and in the init method I was trying to deactivate the rotation. In the debugging mode it worked fine.
- (id)initWithFrame:(CGRect)frame
{
self = [super initWithFrame:frame];
if (self) {
// Initialization code
[self setRotateEnabled:FALSE];
[self initDelegate];
}
return self;
}
Maybe someone knows what's going on? Thanks in advance.
It was a problem in the iOS version. RotateEnabled in available only in iOS7 like Suresh point out. I had to check if the property was there (or check if it has iOS7) like
if ([self respondsToSelector:NSSelectorFromString(elementName)])
{
[self setValue:elementInnerText forKey:elementName];
}

How to find what kind of parameters is required for undocumented version of handleGesture selector (for UIWebView)?

I have added a custom popup menu to UIWebView instance:
- (void)viewDidLoad
{
UILongPressGestureRecognizer* gesture = [[[UILongPressGestureRecognizer alloc]
initWithTarget:self action:#selector(handleGesture::)] autorelease];
}
- (void)handleGesture
{
}
- (void)handleGesture:(UIGestureRecognizer*)gestureRecognizer
{
if (gestureRecognizer.state == UIGestureRecognizerStateEnded) {
[gestureRecognizer.view becomeFirstResponder];
UIMenuController* mc = [UIMenuController sharedMenuController];
[mc setTargetRect: gestureRecognizer.view.frame inView: gestureRecognizer.view.superview];
[mc setMenuVisible: YES animated: YES];
}
And it works! Until I focus textarea (CodeMirror editor) on a webpage. At this case I have the following exception:
-[FirstViewController handleGesture::]: unrecognized selector sent to instance 0x20369c00
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[FirstViewController handleGesture::]: unrecognized selector sent to instance 0x20369c00'
*** First throw call stack:
(0x3608c2a3 0x3439c97f 0x3608fe07 0x3608e531 0x35fe5f68 0x3747ad31 0x374423dd 0x3762f479 0x37366837 0x3736529b 0x360616cd 0x3605f9c1 0x3605fd17 0x35fd2ebd 0x35fd2d49 0x3650f2eb 0x373b1301 0x140bb 0x14060)
libc++abi.dylib: terminate called throwing an exception
(lldb)
I think it's required to implement undocumented version of handleGesture selector with exotic parameters. Is it right? How to find what kind of parameters is required?
The correct code:
initWithTarget:self action:#selector(handleGesture:)] autorelease];

How to rectify the crash related to iAd in my application

I have integrated iAd in my application and i am executiong it in my simulator. I kept the target iOS 4.1. But some times I am getting the error:
"Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[NSCFString bannerViewDidLoadAd:]: unrecognized selector sent to instance 0x6451cd0' " and the application will be quit. What i have to do.
I statically added the ADBannerView in interface builder and used the delegate methods like this:
#pragma mark ADBannerViewDelegate
- (void)bannerViewDidLoadAd:(ADBannerView *)banner {
Class classAdBannerView = NSClassFromString(#"ADBannerView");
if(classAdBannerView!= nil)
iAdView2.hidden = NO;
}
- (void)bannerView:(ADBannerView *)banner didFailToReceiveAdWithError:(NSError *)error
{
Class classAdBannerView = NSClassFromString(#"ADBannerView");
if(classAdBannerView!= nil)
iAdView2.hidden = YES;
}
If any one know the solution please help me.
Exception:
NSInvalidArgumentException', reason:
'-[NSCFString bannerViewDidLoadAd:]: unrecognized selector sent to instance 0x6451cd0' "
Suggests that your delegate object going out of scope. It may be because you have created it in auto-release pool or releasing it somewhere. You will need to retain it.
Thanks

What is wrong with my code? I'm using MBProgressHUD

I'm using MBProgress HUD and I don't know what is the problem.
I have a UIButton that shows the HUD.
This is my code:
- (void)showHUD:(id)sender {
HUD = [[MBProgressHUD alloc] initWithView:self.view];
HUD.mode = MBProgressHUDModeCustomView;
[self.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = #"No Internet Connection...";
HUD.opacity = 0.7;
HUD.customView =
[[UIImageView alloc] initWithImage:[UIImage imageNamed:#"image.png"]];
[HUD showWhileExecuting:#selector(hudWasHidden)
onTarget:self
withObject:nil
animated:YES];
}
- (void)hudWasHidden {
float progress = 0.0f;
while (progress < 1.0f) {
progress += 0.01f;
HUD.progress = progress;
usleep(50000);
}
}
Here is the Console log:
2010-06-11 17:55:26.255 Dual Search[14166:207] * -[MBProgressHUD setCustomView:]:
unrecognized selector sent to instance 0x6321220 2010-06-11 17:55:26.256 Dual
Search[14166:207] Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '** -[MBProgressHUD setCustomView:]:
unrecognized selector sent to instance 0x6321220' 2010-06-11 17:55:26.256 Dual
Search[14166:207] Stack: ( 41853515, 2505499913, 42125115, 41587990, 41584658,
13036, 2853830, 3324117, 3332879, 3328066, 2977128, 2871789, 2903111, 49860988,
41394236, 41390152, 49854621, 49854818, 2895329, 10508, 10362 )
My app always crashes when clicking the UIButton.
Thanks
This is a common crash in Cocoa code: "unrecognized selector" is very explicit in this case. MBProgressHUD doesn't have a customView property, and attempting to set it is causing the crash. The setCustomView is the implicit selector (method) being called here, and Objective-C will crash when a called method isn't there.
Not sure what to tell you about how to accomplish what you're trying to do.