UIPickerView in SKScene - ios

I want to design a level select scene in my game. What I want is a very abstract design which consists of a single UIPickerView that has the width of the screen and about 200 px in height.
The following is from LevelSelect.m , which is a subclass of SKScene
-(id)initWithSize:(CGSize)size{
if (self = [super initWithSize:size]) {
/* Setup your scene here */
self.backgroundColor = [SKColor whiteColor];
for (int i = 0; i < 10; i++) {
NSString* levelString = [NSString stringWithFormat:#"Level %i",i];
[levelData setObject:levelString atIndexedSubscript:i];
}
UIPickerView *levelPickerView = [[UIPickerView alloc] initWithFrame:CGRectMake(self.scene.size.width/2, self.scene.size.height/2, self.scene.size.width, 200)];
levelPickerView.dataSource = self;
levelPickerView.delegate = self;
levelPickerView.showsSelectionIndicator = YES;
[self addChild:levelPickerView];
}
return self;
}
I implemented the UIPickerView data source and delegate methods. But when i load the scene i get the following error .
2014-07-23 22:32:41.222 Poppolo[13686:60b] -[UIPickerView setPaused:]: unrecognized selector sent to instance 0x17d90470
2014-07-23 22:32:41.225 Poppolo[13686:60b] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIPickerView setPaused:]: unrecognized selector sent to instance 0x17d90470'
* First throw call stack:
(0x2dd30f0b 0x384c7ce7 0x2dd34837 0x2dd33137 0x2dc82098 0x304618cb 0xe1f3d 0xe70fb 0x389b0d53 0x389b0d3f 0x389b36c3 0x2dcfb681 0x2dcf9f4d 0x2dc64769 0x2dc6454b 0x32bd16d3 0x305c3891 0xee221 0x389c5ab7)
libc++abi.dylib: terminating with uncaught exception of type NSException
thanks in advance.

Related

jwplayer uncaught exception in ios

I'm trying to implement jwplayer in ios app but using a very simple startup it is continuously throwing signal abort error
#interface ViewController () <JWPlayerDelegate>
#property JWPlayerController *player;
#end
#implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
[self createPlayer];
}
- (void)createPlayer
{
JWConfig *config = [JWConfig configWithContentURL:#"http://content.bitsontherun.com/videos/3XnJSIm4-injeKYZS.mp4"];
config.autostart = YES;
self.player = [[JWPlayerController alloc] initWithConfig:config];
config.size = CGSizeMake(100, 100);
_player.view.frame = CGRectMake(0, 0, 100, 100);
[self.view addSubview:self.view];
}
#end
Error:
jwplayercheck[4111:850586] -[JWConfig xmlPlayList]: unrecognized selector sent to instance 0x1701256e0
2016-12-21 15:14:31.827747 jwplayercheck[4111:850586] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[JWConfig xmlPlayList]: unrecognized selector sent to instance 0x1701256e0'
* First throw call stack:
(0x1820321c0 0x180a6c55c 0x182039278 0x182036278 0x181f3059c 0x1000e38bc 0x1000be750 0x1000b4f68 0x1000b4a00 0x1000d9770 0x1000d97e0 0x1000ab850 0x1000ab7c4 0x187e860b0 0x187e85c78 0x187e8c424 0x187e898c4 0x187efc0e8 0x188108a78 0x18810e5c8 0x188122e60 0x18810b5ac 0x183bd98bc 0x183bd9728 0x183bd9ad0 0x181fe0278 0x181fdfbc0 0x181fdd7c0 0x181f0c048 0x187ef12b0 0x187eec034 0x1000ac414 0x180ef05b8)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
[Change Other Linker Flags on Build Setting to "-all_load"]

iOS : initWithCoder fail : 'Exercised class for selector implementation needs to be pushed'

I have an UIImageView subclassed as CLImageView that has been implemented with lazy load.
Just ago I have encountered this error message :
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Exercised class for selector implementation needs to be pushed'
*** First throw call stack:
at line : if(self=[super initWithCoder:aDecoder]) {
- (instancetype)initWithCoder:(NSCoder *)aDecoder{
if(self=[super initWithCoder:aDecoder]){
self.placeholderImage = nil;
self.delegate = nil;
self.cacheEnabled = NO;
self.prettyLoad = NO;
}return self;
}
I have never seen this error until 5 years of iOS programming, and I could not find any information on this kind of message here.
If anybody can drop me some ideas would be grateful.
If you need more information just leave a comment or reply.
Thank you so much.

I get this error in my code 'NSInvalidArgumentException',

2015-02-03 22:44:17.468 descuentos[1430:55158] -[UIButton value]: unrecognized selector sent to instance 0x7fde78d95440
2015-02-03 22:44:17.472 descuentos[1430:55158] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIButton value]: unrecognized selector sent to instance 0x7fde78d95440'
*** First throw call stack:
How can I fix this error? I think this is a thread error.
Here is my code:
- (IBAction)TipsSlider:(id)sender {
UISlider *slider = sender;
float valorFloat = slider.value;
int valInt = (int)valorFloat;
_dataSlider.text = [[NSString alloc]initWithFormat:#"%d", valInt];
}
- (IBAction)calcular:(id)sender {
UISlider *slider = sender;
float valorFloat = slider.value;
int valInt = (int)valorFloat;
_dataSlider.text = [[NSString alloc]initWithFormat:#"%d", valInt];
float valorIn= [[entrada text] floatValue];
float resultado = (valorFloat / 100) * valorIn;
NSString *resultadoFinal = [[NSString alloc]initWithFormat:#"%4.2f",resultado];
_salidaResultado.text = resultadoFinal;
}
It looks like you have connected an IBAction from a UIButton when you intended to use a UISlider.
You then assign the sender of the action (which is a button) to a slider and try to access its "value", only that UIButton instances do not respond to a "value" message and that's why you get the crash.
So, make sure you are "ctrl+dragging" from a slider in IB.

How to unload previous level (class) in iOS

In my game, when I load a new level, the previous level seems to be still remaining in the view.. Each level has its own class and they all draw something on the screen. So if I have 2 or more levels of images loaded, that makes my game too slow. What can I do to unload the previous level? Thanks in advance..
- (void) finishedLevel: (Level *) level
{
levelNumber++;
levelClass = NSClassFromString([NSString stringWithFormat:
#"Level_%d", levelNumber]);
if (!levelClass) levelClass = [Level class];
currentLevel = [[levelClass alloc] initWithView: self.mainView];
self.mainView.levelLabel.text = [NSString stringWithFormat:#"Level %d", levelNumber];
gameRunning = NO;
}
I tried using the following but didn't really work
levelClass = NSClassFromString([NSString stringWithFormat:#"Level_%d", levelNumber-1]);
[levelClass removeFromSuperview];
Error message
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[Level_1 removeFromSuperview]: unrecognized selector sent to class 0x107644'

use subclass of CCLayer for CCScrollLayer

I've created a custom class which is a subclass of CCLayer and trying to use it for CCScrollLayer
The way I do it is:
//Store the my layers to an NSMutableArray
for (AACustomClassLayer *cardLayer in levels) {
[layers addObject:cardLayer];
}
Under the hood of CCScrollLayer it crashes at:
- (void) updatePages
{
// Loop through the array and add the screens if needed.
int i = 0;
for (CCLayer *l in layers_)
{
l.anchorPoint = ccp(0,0);
l.contentSize = [CCDirector sharedDirector].winSize;
l.position = ccp( (i * (self.contentSize.width - self.pagesWidthOffset)), 0 );
if (!l.parent)
[self addChild:l];
i++;
}
}
The implementation for the AACustomClassLayer class (subclass of CCLayer) looks like:
-(id)initWithChapter:(AALevel *)level {
self = [super init];
if (self) {
self.isTouchEnabled = YES;
//Here I'm adding the CCSprite to my layer
}
return self;
}
UPDATE:
Crash log
2012-04-20 14:12:12.344 [15780:10a03] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setAnchorPoint:]: unrecognized selector sent to instance 0x884ab40'
*** First throw call stack:
(0x1a75022 0x200fcd6 0x1a76cbd 0x19dbed0 0x19dbcb2 0xd013f 0xcfe2b 0x102370 0x44c15 0xbe45f 0x8a94be 0x8aa274 0x8b9183 0x8b9c38 0x8ad634 0x282def5 0x1a49195 0x19adff2 0x19ac8da 0x19abd84 0x19abc9b 0x8a9c65 0x8ab626 0xbda06 0x22e5)
terminate called throwing an exception
I've found it!
for (AACustomClassLayer *cardLayer in levels) {
cardLayer = [[AACustomClassLayer node] autorelease];
[layers addObject:cardLayer];
}
You should add a conditional check in your for loop that determines if the object you are getting from enumeration is in fact a CCLayer. Your crash log states that the anchorPoint setter was not available on some object, presumably on an object in your layers_ array since that is the code you have posted that deals with anchorPoints.
Enumeration is convenient, but you are casing all objects to CCLayer when it is possible that one of them is not. I don't know where you are adding objects to layers_ but is it possible you are adding an object that is not actually a CCLayer ?

Resources