I have a xamarin forms IOS app that runs great in the simulator but when installed on my iphone none of the buttons work. I have app center debugging in there so I can see it never even gets into the button logic. After reading some posts, I even pulled the button out and put it into a separate frame to ensure nothing was overlaying it, but that did nothing. I could really use some help.
Here is my xaml
<ContentPage.BindingContext>
<ViewMode:EnterCarViewModel/>
</ContentPage.BindingContext>
<Grid BackgroundColor="Purple">
<Grid.RowDefinitions>
<RowDefinition Height="47"/>
<RowDefinition Height="30"/>
<RowDefinition Height="20"/>
<RowDefinition Height="30"/>
<RowDefinition Height="35"/>
<RowDefinition Height="45"/>
<RowDefinition Height="30"/>
<RowDefinition Height="45"/>
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
<RowDefinition Height="35"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="65"/>
<ColumnDefinition Width="15"/>
<ColumnDefinition Width="105"/>
<ColumnDefinition Width="25"/>
<ColumnDefinition Width="85"/>
<ColumnDefinition Width="65"/>
</Grid.ColumnDefinitions>
<Frame BackgroundColor="#2196F3" Padding="10" CornerRadius="0" Grid.ColumnSpan="6" Grid.Row="0">
<Label Text="Enter Car" HorizontalTextAlignment="Center" TextColor="White" FontSize="25" />
</Frame>
<Label Text="{Binding EntError}" BackgroundColor="White" HorizontalTextAlignment="Center" TextColor="Red" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="6" FontSize="20" />
<Label Text="Year:" TextColor="White" FontSize="Medium" Grid.Row="3" Grid.Column="0" Margin="5" />
<Entry Text="{Binding EntYear}" Keyboard="Numeric" BackgroundColor="White" TextColor="Black" Grid.Row="3" Grid.Column="1" Margin="0" Grid.ColumnSpan="2" >
<Entry.Behaviors>
<Validate:MaxLengthValidator MaxLength="4"/>
</Entry.Behaviors>
</Entry>
<Label Text="Name:" TextColor="White" FontSize="Medium" Grid.Row="5" Grid.Column="0" Margin="6"/>
<Entry Text="{Binding EntName}" TextColor="Black" Keyboard="Default" BackgroundColor="White" Grid.Row="5" Grid.Column="1" Grid.ColumnSpan="4" Margin="6" >
<Entry.Behaviors>
<Validate:MaxLengthValidator MaxLength="30"/>
</Entry.Behaviors>
</Entry>
<Label Text="Default:" TextColor="White" FontSize="Medium" Grid.Row="7" Grid.Column="0" Margin="5" Grid.ColumnSpan="2"/>
<Switch IsToggled="{Binding IsChecked, Mode=TwoWay}" Grid.Column="2" Grid.Row="7" IsVisible="true"/>
<Frame BackgroundColor="#2196F3" Padding="10" CornerRadius="0" Grid.ColumnSpan="3" Grid.Row="9">
<Button x:Name="MyButton" Command="{Binding AddCarData}" IsEnabled="True" Text="Add Car" BackgroundColor="Yellow" Grid.Column="1" Grid.ColumnSpan="2" TextColor="Black"/>
</Frame>
</Grid>
Here is the ViewModel which contains the code for the button
public Command AddCarData => new Command(() =>
{
Analytics.TrackEvent("Top of AddCarData. EntYear = " + EntYear + " EntName = " + EntName);
bool errorFound = false;
IsVisibleLabel = false;
IsVisibleResults = false;
if (EntYear == string.Empty || EntYear == null)
{
IsVisibleLabel = true;
EntError = "You Must Enter Year";
errorFound = true;
}
else if (!errorFound)
{
Regex regex = new Regex(@"^[1-9]\d{3,}$");
Match match = regex.Match(EntYear);
if (!match.Success && !errorFound)
{
IsVisibleLabel = true;
EntError = "Year Must Be 4 Numbers";
errorFound = true;
}
else if ((Convert.ToInt32(EntYear) < 1900) && !errorFound)
{
IsVisibleLabel = true;
EntError = "You Must Enter a Car Name";
errorFound = true;
}
}
if (EntName == null && !errorFound)
{
IsVisibleLabel = true;
EntError = "You Must Enter a Car Name";
errorFound = true;
}
Analytics.TrackEvent("In AddCarData. errorFound = " + errorFound);
if (!errorFound)
{
var isDefault = false;
if (IsChecked)
{
isDefault = true;
}
else
{
isDefault = false;
}
MileageItemRepository repository = new MileageItemRepository();
if (IsChecked)
{
var autoResults = repository.GetAuto2();
foreach (var item in autoResults)
{
if (item.IsDefault)
{
var resp = repository.UpdateAutoAsync(false, item.Id);
}
}
App.Current.Properties["processedChange"] = false;
}
AutoTableDefination data = new AutoTableDefination()
{
IsDefault = isDefault,
CarYear = EntYear,
CarDesc = EntName
};
int results = repository.AddAutoData(data).Result;
Analytics.TrackEvent("In AddCarData Results from AddAutoData. results = " + results);
if (results == 1)
{
IsVisibleResults = true;
EntResults = "Entered Successfully";
if (Convert.ToBoolean(App.Current.Properties["firstAutoEntered"]))
{
App.Current.Properties["autoId"] = 1;
App.Current.Properties["firstAutoEntered"] = false;
}
var nav = MyNavigation.GetNavigation();
nav.PushAsync(new UpdateCars());
}
else
{
IsVisibleResults = true;
EntResults = "Error, Please Try Again";
}
}
});
This is really perplexing so if anyone can help me with this, it would be greatly appreciated.