I can't seem to get the value I want from UIStepper - ios4

I am using iOS 5.0 and I'm trying to get a value from my UIStepper.
I set the minimum to 0.0
The maximum is 25.0
The step value is 1.0
The starting value is 15.0
If I tap the + button ten times, the + will grey out so I know I'm at the max.
I've wired the "value changed" event in the uistepper to an IBAction called stepulate
That method only has an NSLog
Looks like
NSLog(#"%d", [myStepper value]);
I keep getting zero printed. No matter how many times I tap the + or - button.

The UIStepper uses a float for its value. Try this:
NSlog(#"Stepper Value: %.f", [stepper value]);

double stepperValue = rating_pound_stepper.value;
self.lbl_pound_rating.text = [NSString stringWithFormat:#"%.f", stepperValue];

try
NSLog(#"%d", [myStepper intValue]);

Related

Revit API changes wall parameters: from metadata it showed the correct result, not reflected in UI however

Using revit-python-wrapper to create Wall then adjust the Wall height and Wall offset to the ground.
Here is the code
from rpw import db
from rpw import DB
start_point = XYZ(0, 0, 0)
end_point = XYZ(45, 0, 0)
# Wrapper Line
line = Line.new(start_point, end_point)
levels = db.Collector(of_class='Level')
level_0 = levels.get_first()
wall = DB.Wall.Create(doc, line.unwrap(), level_0.Id, False)
w = db.Wall(wall)
w.parameters['Unconnected Height'].value = 2675
w.parameters['Base Offset'].value = 45
Wall created successfully in the empty Revit project.
Using snoop revit DB, only one wall is found. The ID is : 318835
Checked the parameters belonging to this Wall - 318835. The parameter 'Unconnected Height' has correct double value: 2675.0 and the parameter "Base Offset" has correct double value: 45.0.
So far, everthing is perfect and per my expectation.
But, from the UI interface, the only Wall created is shown in wrong position. In 3D view, it's above the Level 1 which height is 4000.
And from the proporty tab of the selected Wall, the two parameters are also in the wrong values.
'Unconnected Height' has correct double value: 815340.0 and the parameter "Base Offset" has correct double value: 13716.0.
When I digged into deeper, I found actually the value I changed is shown in AsDouble. However, the value I changed in the UI is shown AsValueString. Both of them are pointing to the same property. However they are different, my understanding they should be the same value but in different data format.
Am I wrong?
I figured it out now.
Internally, Revit use feet rather than mm.
So, make sure convert the mm to feet then pass it to value.
w.parameters['Unconnected Height'].value = mm_to_feet(2675)
w.parameters['Base Offset'].value = mm_to_feet(45)

How can I change the opacity of a button in a if statement in kotlin

I'm making and app and I'm in the register/login, I would like to do something similar as instagram does when the email/username or password are empty or the password does not have enough character (8 or more) the button opacity is reduced and when all is correct is 100%, as I'm starting in kotlin and I don't have any knowledge in java I don't know if this is possible
if(email.isEmpty() || password.isEmpty()){
Toast.makeText(this, "please enter text in email/password",Toast.LENGTH_SHORT).show()
return#setOnClickListener
}
what I'm trying to achieve is that in the if statement when else, opacity of button 50%, when if correct opacity of button 100%
the button is located in activity_register and the button id is registrar_button_register and the
in the if statement also I donĀ“t know how to add that until the password has 8 or more characters the if statement is not completed
could it be done? and how?
To set the opacity for a View, change it's alpha value.
registrar_button_register.alpha = 0.5f
You could even animate the opacity change using animate()
registrar_button_register.animate().alpha(0.5f).setDuration(200)
use this code :
if (your condition) {
yourButton.setAlpha(1f);
} else {
yourButton.setAlpha(0.5f);
}

Why isn't my path2d position updating?

I created a new path2d following the instructions in the my first game article: http://docs.godotengine.org/en/3.0/getting_started/step_by_step/your_first_game.html
I wanted to move the "box" on screen so that I could see how the mobs spawn in, but when I ran the scene, it stayed off screen.
I created a new path2d, centered this one in the middle of the screen, and it works like I wanted it to, but now I moving this one in the editor doesn't update the position in game.
What's going on?
Thanks
func _on_mobtimer_timeout():
$mobtimer.wait_time = 0.1 + randf() / 2
$mobspawn/moblocation.set_offset(randi())
var mob = Mob.instance()
add_child(mob)
var direction = $mobspawn/moblocation.rotation + PI/2
mob.position = $mobspawn/moblocation.position
direction += rand_range(-PI/8, PI/8)
mob.rotation = direction
mob.set_linear_velocity(Vector2(rand_range(200, 200 + score * 30), 0).rotated(direction))
A Node2D's position property is relative to it's parent's position. The code from the Dodge The Creeps tutorial assumes that MobPath is located at 0, 0 and fails when that assumption is false.
In your case you are taking a MobSpawnLocation's position relative to MobPath and then setting it as the new Mob's global position.
Luckily Node2D's have another property that we can use in these circumstances global_position. It can be used like this:
mob.position = $mobspawn/moblocation.global_position
http://docs.godotengine.org/en/stable/classes/class_node2d.html#member-variables
This isn't a full solution, but I found a weird workaround. Instead of changing the position in the editor, if you use the nodes on the orange box (at the intersection of orange and blue), you can kind of alternate to move the box around.

How to convert the normal text to bold text?

I have this code in my Dialog:
//other code
dialog.addText(strFmt("Delete this field's value: %1?", MyTable.FieldTable));
//other code
I have an output looklike:
I know the strUpr function:
dialog.addText(strFmt("Delete this field's value: %1?", strUpr(MyTable.FieldTable)));
Does there exist a method or function to convert only the FIELDValue to bold text?
You can set the bold property to 7 on FormBuildStaticTextControl.
Control can be obtained via the control method on DialogText returned by addText method.
The integer that is returned contains the weight of the font as follows:
0 Use the default font weight.
1 Thin.
2 Extra-light.
3 Light.
4 Normal.
5 Medium.
6 Semibold.
7 Bold.
8 Extra-bold.
9 Heavy.
Example:
Dialog dialog = new Dialog();
DialogText dt = dialog.addText("Test");
FormBuildStaticTextControl txtCtl = dt.control();
txtCtl.bold(7);
dialog.run();
A working example using addFieldValue (similar to Matej's solution):
Dialog dialog = new Dialog("Dialog example");
DialogField f1 = dialog.addFieldValue(extendedTypeStr(String30), 'Value', "Delete this field's value?");
FormBuildStringControl c1 = f1.control();
c1.allowEdit(false);
c1.skip(true);
c1.bold(7);
c1.viewEditMode(ViewEditMode::View);
dialog.run();
I doubt that Dialog class has the ability to display bold text, at least I haven't seen such, neither did I find any method to format text in a dialog. One solution would be to create custom form that looks like a dialog box, but I think it is redundant.
Regarding uppercase, you can use strUpr (link) method:
//other code
dialog.addText(strUpr(strFmt("Delete this field's value: %1?", MyTable.FieldTable)));
//other code

Move MKMapView legal label on rotation

I have an MKMapView with an iAd banner on top. Due to this iAd Banner covering the MKMapView's legal label, it is moved. The following code is performed in viewDidLayoutSubviews:
NSLog(#"ViewDidLayoutSubviews called");
UILabel *attributionLabel = [self.mapView.subviews objectAtIndex:1];
if (adBannerViewFrame.origin.y < attributionLabel.frame.origin.y) {
NSLog(#"Banner Y coordinate: %f", adBannerViewFrame.origin.y);
CGRect legalFrame = attributionLabel.frame;
legalFrame.origin.y -= IAD_BANNER_HEIGHT;
attributionLabel.frame = legalFrame;
NSLog(#"Legal y: %f", legalFrame.origin.y);
NSLog(#"Legal x: %f", legalFrame.origin.x);
NSLog(#"Legal width: %f", legalFrame.size.width);
NSLog(#"Legal height: %f", legalFrame.size.height);
}
When I switch from the View Controller containing the map to another VC and back again, the code above works perfect, regardless of orientation; however, when rotating the devices without switching VCs, the legal label disappears on rotation and don't come back until I switch back and fourth between VCs again. The NSLogs print out the exact same for both rotation and VC switching:
ViewDidLayoutSubviews called
Banner Y coordinate: 902/646(rotation dependent)
Legal x: 882/626(rotation dependent)
Legal y: 11
Legal width: 48
Legal height 11
Despite everything looking the same, the label is gone after rotating (not sure if it is moved out of the view or if it actually disappears)
The iAd Banner is reloaded in ViewDidAppear (which is called when VCs are switched back and fourth). However, since the NSLogs print the same for both scenarios, I cannot see how it should make any difference. To be sure, I tried to reload the iAd Banner in ViewDidLayoutSubviews as well, with no different result than before. Anyone experienced anything similar or know how to fix this?
For anyone encountering the same issue, I found a solution. The workaround was to schedule a timer with 0 seconds and have the timer call the method executing the code above.
[NSTimer scheduledTimerWithTimeInterval:0 target:self selector:#selector(test) userInfo:nil repeats:NO];
I assume that something was not completely finished when viewDIDlayoutSubviews was called and that adding a timer (which is not 100 % accurate and will therefore not start immediately), allowed the unknown remaining stuff to complete before the code in the question was executed.

Resources