How can the JDFlipNumberView frame be changed? - iphone

I downloaded JDFlipNumberView from here.
It works but there is a problem with the frame. To change the frame the developer has said to use:
flipNumberView.frame = CGRectMake(10,100,300,100);
but when I do this it doesn't change.
PS: when I put NSLog(#"%#",flipNumberView.frame); it returns null.
How can I change the frame?

"fram' is not a string, it is structure's object.so if you want see frame. you can use it.
NSLog(#"Width = %f",btn.frame.size.width);
NSLog(#"height = %f",btn.frame.size.height);
NSLog(#"x = %f",btn.frame.origin.x);
NSLog(#"y = %f",btn.frame.origin.y);
may be it help for you.

If you use the example project, you need to deactivate the layoutSubviews: method first. It resets the frame on every relayout.
Otherwise just set a new frame.

Related

Round UIImage disappear

I set my image works well like this:
self.avatarImageView.image = self.avatarImage
But, when i want to change it to circle in this way the image disappear.
self.avatarImageView.layer.masksToBounds = true
self.avatarImageView.image = self.avatarImage
self.avatarImageView.layer.cornerRadius = self.avatarImageView.frame.width/2
Add this line to layout it works.
self.avatarImageView.layoutIfNeeded()

CoreGraphics prevents frame modifications on other objects?

Just getting started with iOS development, so please forgive my ignorance here. I've also searched for a while without success on this topic, but I'm sure I'm just not searching the right terms.
If I comment out the only line in this first for loop, the next for loop seems to function exactly how I expect. If I leave them both in then, I only see the CG stuff happening and the other objects sit still.
What does the transformation on the object currentGear have to do with the frame being changed on another object within the same view? Why would performing the transformation invalidate the frame change after it?
for (UIImageView *currentGear in self.imageGearCollection)
{
currentGear.transform = CGAffineTransformRotate(currentGear.transform, (90*M_PI)/180);
}
for (UIButton *currentCrate in self.buttonCrateCollection)
{
CGRect rectFrame = currentCrate.frame;
rectFrame.origin.x += 10;
currentCrate.frame = rectFrame;
}
Your question doesn't really have anything to do with Core Graphics.
The UIView Class Reference says this about frame:
Warning: If the transform property is not the identity transform, the value of this property is undefined and therefore should be ignored.
So what you're doing is not really allowed.
Since you're just trying to move the view, not change its size, you can do that by modifying its center property instead:
CGPoint center = currentCrate.center;
center.x += 10;
currentCrate.center = center;

Location of node is always null. Cocos3d

I'm trying to get the position of my camera in cocos3d, but am having trouble. Here's what my initializeWorld looks like
[self addContentFromPODFile: #"leggo.pod"];
CC3Camera* cam2 = (CC3Camera*) [self getNodeNamed:#"Camera"];
[self addChild:cam2];
//the location and rotation is just for testing
//cam2.location = cc3v(0,57.101,71.694);
//cam2.rotation = cc3v(-38,0,0);
CC3Vector camLoc = cam2.location;
NSLog(#"cam2 position is x=%# y=%# z=%#", camLoc.x, camLoc.y, camLoc.z );
Can anyone tell me why the value of camLoc.x, camLoc.y, and camLoc.z are always null? I tried getting the location after a delay, but they are still null. I'm out of ideas. It seemed like I was getting close with this similar issue, but I still can't figure it out. Thanks
They're null because you use the wrong format string. %# is only for id types but the coordinates are simple float values. Instead use this:
NSLog(#"cam2 position is x=%f y=%f z=%f", camLoc.x, camLoc.y, camLoc.z);
PS: learn to use the debugger. If you had set a simple breakpoint and had a look at the local variables you would have seen right away that the values aren't really "null".

How can we know that map Coordinates are in current region or not in current region?

I am working on map view app.I want know that how we can identify that coordinates are in my current region(Map region that bound with screen) or outside of it.
Thanks In Advance.
You have different options. You can see this sample code from apple: Regions. That, has I understand, check the device position by the antenna's position.
Or tracking device position, and check if is inside a region defined by You. Check this question
If you find a better solution, please let me know.
EDIT:
To check if a coordinate is visible in the map try using this:
// Your coordinates - Lisbon for example
float lisbonLatitudeValue = 38.7069320;
float lisbonLongitudeValue = -9.1356321;
CLLocationCoordinate2D lisbonCoordinates = CLLocationCoordinate2DMake(lisbonLatitudeValue, lisbonLongitudeValue);
if (MKMapRectContainsPoint(mapView.visibleMapRect, MKMapPointForCoordinate(lisbonCoordinates)))
{
// do something
NSLog(#" - Lisbon is visible");
}
else {
// do something
NSLog(#" - Lisbon is not visible");
}
Hope it helps

Cocos2D getting progress of CCAction

I have a Cocos2D game with Box2D physics. In my GameScene.mm, I'm working on a method to zoom to a given scale:
-(void) zoomToScale:(float)zoom withDuration:(ccTime)duration
{
id action = [CCScaleTo actionWithDuration:duration scale:zoom];
[scrollNode runAction:action];
currentZoomLevel = zoom;
}
The problem that I'm having is that currentZoomLevel (which is used in the Scene's update() method) is set to the zoom immediately, and isn't gradually adjusted as per the animation. So while the animation is in progress, the currentZoomLevel variable is totally wrong.
I'm trying to figure out a way to have the currentZoomLevel variable match the progress of the animation as it's happening. According to the CCAction API Reference, the CCAction's update method takes a ccTime that's between 0 and 1 based on the progress of the animation (0 is just started, 1 is just finished).
How can I access this ccTime from outside of the action? I want to have something in my Scene's update method like this:
if(animating)
{
float progress = [action getProgress]; // How do I do this?
// Do math to update currentZoomLevel based on progress
}
Am I missing something obvious here, or am I going to have to subclass CCScaleTo?
You should be able to access the scale directly as it animates.
instead of
float progress = [action getProgress];
try
float current_scale = some_node.scale ;
where "some_node" is the thing you're animating/scaling.
Actually, your best bet is to use the new Cocos2D extension "CCLayerPanZoom", which handles all of this marvellously for you! It should be part of any new cocos2D install (v.1.0+).