Answer the question
In order to leave comments, you need to log in
Why don't xamarin buttons work?
I am doing a project following the example https://docs.microsoft.com/en-us/xamarin/ios/get-s... I click on the call or translate buttons and the application freezes stupidly
public partial class ViewController : UIViewController
{
public ViewController(IntPtr handle) : base(handle)
{
}
public override void ViewDidLoad()
{
base.ViewDidLoad();
string translatedNumber = "";
TranslateButton.TouchUpInside += (object sender, EventArgs e) => {
translatedNumber = PhoneTranslator.ToNumber(
PhoneNumberText.Text);
PhoneNumberText.ResignFirstResponder();
if (translatedNumber == "")
{
CallButton.SetTitle("Call ", UIControlState.Normal);
CallButton.Enabled = false;
}
else
{
CallButton.SetTitle("Call " + translatedNumber,
UIControlState.Normal);
CallButton.Enabled = true;
}
};
CallButton.TouchUpInside += (object sender, EventArgs e) => {
var url = new NSUrl("tel:" + translatedNumber);
if (!UIApplication.SharedApplication.OpenUrl(url))
{
var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
PresentViewController(alert, true, null);
}
};
}
public override void DidReceiveMemoryWarning()
{
base.DidReceiveMemoryWarning();
}
Answer the question
In order to leave comments, you need to log in
@melkaya94, <code lang="javascript">
async handleOnClick(i){
await this.setState({
selectCard: {
...this.state.selectCard,
[i]: !this.state.selectCard[i]
}
},() => {this.amountSelectSwatches(this.state.selectCard,i)}); // вызов счетчика
}
amountSelectSwatches(obj,ind){
if(obj[ind]===true){
await this.setState({
count:Object.assign({},this.state.count,{[ind]:++this.state.count[ind]})
})
}}
</code>
если вам это не нравится вы можете использовать глобальную переменную для хранения count
You have chosen a strange way of storing selected cards. Why do you need an object? Store just an array.
Example
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question