Code doesn't work on iPhone but works on simulator - iphone

I have this code in my live chat.
if (TRUE && (balloonsOn != NO || !htmlStart)) {
balloonsOn = TRUE;
htmlStart = [self createChatLines: balloonsOn ? #"htmlformat-balloons" : #"htmlformat"];
if (chatLines > 0){
chatLines = 0;
[self updateView];
}
}
On the simulator it works fine but on the phone it doesn't work. It has worked before many times but now it stopped working on the phone. Why is this happening?

As far as I can see, there should be nothing that wouldn't work on the iPhone.. The only thing I can suppose, is you are using that strings without caring of the case-sensitiveness of iOs. The simulator is case insensitive but iOs is.. Let me know :)

What is the variable 'TRUE' ? I think having that as a variable name is probably the issue, rename it something else and see if it works.

Related

Native Device Orientation issue in Flutter

I'm working with Flutter and I'm using Native Device Orientation Plugin
I'm trying to know the device orientation and manage my view based on that.
That plugin works really well, but I found an issue when I'm in page A which has a NativeDeviceOrientationReader and go to page B which has another NativeDeviceOrientationReader.
In this case, the page which is supposed to has a NativeDeviceOrientation.landscapeLeft will have NativeDeviceOrientation.landscapeRight even if I didn't change the orientation in the middle.
Note: If I rotate the phone after changing the page, it begins to work properly.
Also if I delete one of the NativeDeviceOrientationReader's it works ok too.
I'm using this code:
NativeDeviceOrientationReader(
builder: (context) {
NativeDeviceOrientation orientation = NativeDeviceOrientationReader.orientation(context);
var quarterTurns = 0;
if (orientation == NativeDeviceOrientation.landscapeLeft) {
quarterTurns = 3;
} else if (orientation == NativeDeviceOrientation.landscapeRight) {
quarterTurns = 1;
}
}
),
(...)
I don't know if somehow I have to close the reader or something.
Thanks in advance !
-------------- EDIT 1 --------------
Actually I didn't fix the issue, but I could resolve my problem changing one NativeOrientationReader to flutter OrientationBuilder, because I realized I didn't need the current rotation, I only wanted to know if the phone is landscape or portrait.
Thank you.

SCNCamera.exposureOffset not working in iOS13

SCNCamera.wantsHDR is true. Yet any changes to SCNCamera.exposureOffset are not visible on iOS13 devices. But it is working perfectly fine on iOS12.
if let camera = self.sceneView.pointOfView?.camera {
camera.exposureOffset = -5
}
You said absolutely right, if someone wanna use exposureOffset instance property in SceneKit, he/she needs to activate a wantsHDR property at first:
var wantsHDR: Bool { get set }
In real code it might look like this:
sceneView.pointOfView!.camera!.wantsHDR = true
sceneView.pointOfView!.camera!.exposureOffset = -5
But there's a bug in iOS 13 and iOS 13 Simulator. However, if you disable allowsCameraControl, exposureOffset works fine.
sceneView.allowsCameraControl = false
Here's how exposureOffset changes from -2 to 2:

Phaser multitouch (on laptop trackpad)

I'm confused by how to skip the following condition when 1) holding down, and then 2) another tap on the screen to release the aim. I think the secondary tap becomes the activePointer so I'm quite puzzled.
var holding_down = game.input.activePointer.isDown;
if (holding_down && game.input.pointer2.isUp) { cue.aiming = true; }
UPDATE: Please note that for the solution accepted, I had to differentiate between desktop and mobile usage. pointer1 & pointer2 work fine on mobile, but on desktop I had to do the following.
if (desktop) {
var holding_down = game.input.activePointer.leftButton.isDown;
var second_tap = spacebar.isDown;
} else {
var holding_down = game.input.pointer1.isDown;
var second_tap = game.input.pointer2.isDown;
}
Also note you need to declare the desktop var after intantating the game object. I then set the var in the preload() function: desktop = game.device.desktop;, otherwise it was giving the wrong value. Thanks!
You're correct in that the secondary tap becomes the activePointer. Per the documentation, activePointer is "[t]he most recently active Pointer object."
Therefore, you'll want to make your checks against game.input.pointer1 and game.input.pointer2 instead.
So replace activePointer in your code with pointer1 and that might get you closer to what you were looking for.

Code will not work without CCLOG in Cocos2D

I'm currently working on a game that will randomly generate a dungeon for the player. This is made up of a whole heap of different methods being called from different files. I seem to have the code working to be able to calculate how much space is available on the other side of the door.
There is a catch however; the code only seems to work when I am outputting to the console using CCLOG. I wrote a good chunk of the code without testing and decided to then work through it in steps to see how the code worked (I figured I would just get it to run without bugs and next I will check my values).
After I had established that the code was successfully checking available space in each direction, while listing the locations it had checked, I decided that I would like to remove the CCLOG output. Unfortunately though, doing this caused the code to stop working.
//First check "forward"
bottom = CGPointMake(startLocation.x + forwardDirectionModifier.x, startLocation.y + forwardDirectionModifier.y);
top = bottom;
do
{
currentLocation = CGPointMake(top.x + forwardDirectionModifier.x, top.y + forwardDirectionModifier.y);
tileType = [tileCache getTileType:currentLocation];
if (tileType == TileTypeFiller)
{
top = currentLocation;
CCLOG(#"Top location is %#", NSStringFromCGPoint(top));
}
} while (tileType == TileTypeFiller || top.y != 63);
This is a small snippet from the code; It is the section of code I think is most likely the issue. Essentially the problem is that if I comment out or delete the line CCLOG(#"Top location is %#", NSStringFromCGPoint(top)); it will stop working.
Here are some more details:
I have several little chunks of code like this, as long as I CCLOG in each one, it will be able to move to the next. If i were to comment out any of them, it would stop progress to the next chunk.
I can change the CCLOG to output anything and it will still work, it just has to be there.
I have tried cleaning the project.
There are more CCLOG's that aren't used inside any loops and they can be removed without consequence.
Does anyone have a solution to this? As far as I can tell, whether I do or do not output something to the console,it shouldn't have an effect on whether or not the code will execute.
Thanks in advance.
EDIT: At Ben Trengrove's suggestion, I am adding in further examples of where the CCLOG is being used.
This code immediately follows the previously listed code.
//Check left relative to door
farLeft = CGPointMake(startLocation.x + leftDirectionModifier.x, startLocation.y + leftDirectionModifier.y);
do
{
currentLocation = CGPointMake(farLeft.x + leftDirectionModifier.x, farLeft.y + leftDirectionModifier.y);
tileType = [tileCache getTileType:currentLocation];
if (tileType == TileTypeFiller)
{
farLeft = currentLocation;
CCLOG(#"Far Left location is %#", NSStringFromCGPoint(farLeft));
}
} while (tileType == TileTypeFiller || farLeft.x !=0);
//Check forwards from far left
top2 = farLeft;
do
{
currentLocation = CGPointMake(top2.x + forwardDirectionModifier.x, top2.y + forwardDirectionModifier.y);
tileType = [tileCache getTileType:currentLocation];
if (tileType == TileTypeFiller)
{
top2 = currentLocation;
CCLOG(#"Top2 location is %#", NSStringFromCGPoint(top2));
}
} while ((tileType == TileTypeFiller)|| (top2.y != 63));
What does your tile cache return as a tileType when there is no tile at currentLocation ? TileTypeFiller by any chance ? if yes, you have an almost certain never ending loop there, under the right circumstances..
EDIT :
please add a line after the loop
CCLOG(#"");
and place a breakpoint on that line. See if the program stops there.
So the problem has now been solved, it seems that in part there was a fault in my logic.
Here is what I've done that now works:
do
{
currentLocation = CGPointMake(top.x + forwardDirectionModifier.x, top.y + forwardDirectionModifier.y);
tileType = [tileCache getTileType:currentLocation];
if (tileType == TileTypeFiller)
{
top = currentLocation;
}
locationCount++;
} while ((tileType == TileTypeFiller) && (locationCount != 15));
CCLOG(#"Top location is %#", NSStringFromCGPoint(top));
The change is that I've switched to AND as opposed to OR. I also changed the second part of the while as I realised that due to my max room size, I never needed to check more than 15 locations in any given direction.
Thanks a lot to everyone that has helped. I'm still not entirely sure though how the use of CCLOG was somehow able to help get past a fault in logic but at least it is working now.

jump into "audioPlayerDidFinishPlaying" function unexpected

I used an AVAudioPlayer object to control playing multiple music files. I also created an UISlider to control seeking file. But i have a problem when seek the pointer. After seeking, AVAudioPlayer update time correct then jump into "audioPlayerDidFinishPlaying" function unexpected.
Here is the code that i used :
-(void)timeChange
{
_player.currentTime = _timeControl.value;
[self updateCurrentTimeForPlayer];
}
-(void)updateCurrentTimeForPlayer
{
if(_isNeedUpdate == NO) return;
_timeControl.maximumValue = _player.duration;
}
A long shot, but maybe the audio format doesn't support seeking?
Why the call to updateCurrentTimeForPlayer? Where is _isNeedUpdate set? (Why all the underscores?)
Can you add some debug NSLogs to find out what's going on?