以下是我的按钮动作事件代码。
-(IBAction)reportRepair{
if(![Common hasReportRepairURL]){
NSArray *forms = [[self delegate] getFormsForSection:@"REPORTREPAIR"];
if(forms.count == 0){
[self performSegueWithIdentifier:@"ReportRepairView" sender:self];
}else if(forms.count == 1)
[self getFormByFormID:[[forms objectAtIndex:0] intValue]];
else
[self performSegueWithIdentifier:@"FormsView" sender:self];
}
}
并且prepareForSegue如下:
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if([[segue identifier] isEqualToString: @"RepairDetailView"]){
RepairDetailViewController *dest = (RepairDetailViewController *) [segue destinationViewController];
dest.job = self.selectedJob;
dest.tenancy = self.tenancy;
}else if([[segue identifier] isEqualToString: @"ReportRepairView"]){
ReportRepairViewController *dest = (ReportRepairViewController *) [segue destinationViewController];
dest.tenancy = self.tenancy;
}else if([[segue identifier] isEqualToString: @"FormsView"]){
FormsSearchViewController *dest = (FormsSearchViewController *) [segue destinationViewController];
dest.allowedForms = [[self delegate] getFormsForSection:@"REPORTREPAIR"];
dest.tenancy = self.tenancy;
dest.formSectionType = @"REPORTREPAIR";
}else if([[segue identifier] isEqualToString: @"FormView"]){
FormViewController *dest = (FormViewController *) [segue destinationViewController];
dest.form = self.form;
dest.tenancy = self.tenancy;
dest.formSectionType = @"REPORTREPAIR";
}
else if([[segue identifier] isEqualToString: @"RepairsWebView"]){
WebViewController *dest = (WebViewController *) [segue destinationViewController];
dest.siteURL = [Common getReportRepairURL:self.tenancy];
dest.screenTitle = AGLocalizedString(@"Report a Repair", @"Report a Repair");
}
}
当我调试代码时,我知道,在Action事件之前会调用prepareForSegue方法。因此,从UI的角度来看,我在应用程序中遇到一些异常行为。