UIPopoverController在iPad上崩溃但在iPad模拟器上运行

时间:2014-12-18 22:21:14

标签: ios ipad crash exc-bad-access uipopovercontroller

我有一个iPad应用程序,它有一个从seque调用的UIPopOverController。按下按钮时会显示弹出窗口。用户从弹出窗口中选择一个项目,并且弹出窗口被解除。但是,当用户第二次按下按钮时,应用程序崩溃。奇怪的是,它在模拟器中运行良好,但在iPad设备上运行它会崩溃。我收到以下错误:EXC_BAD_ACCESS。以下是我的代码:

@interface ViewController : UITableViewController<KeypadDelegate,PickerDelegate,UIPopoverControllerDelegate,UIPickerViewDataSource,UIPickerViewDelegate,UITextFieldDelegate>    
@property (strong,nonatomic) UIPopoverController *myPopOver;
@end

@implementation ViewController
//...
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender 
{
   if ([segue.identifier isEqualToString:@"popOverSearchCustomerSegue"])
   {

       if([segue isKindOfClass:[UIStoryboardPopoverSegue class]])
       {
           [self.myPopOver dismissPopoverAnimated:YES];
           self.myPopOver = [(UIStoryboardPopoverSegue *)segue popoverController];
       }
       UIStoryboardPopoverSegue *popoverSegue = (UIStoryboardPopoverSegue *)segue;
    self.myPopOver = popoverSegue.popoverController; // this is where it errors out on the second time the button is pushed.
    [segue.destinationViewController setDelegate:self];
   }
   else if ([segue.identifier isEqualToString:@"pushProposalSegue"])
   {
       ProposalViewController *propViewController = segue.destinationViewController;
       propViewController.customerID = cust.ID;
       propViewController.customerTitle = self.title;
   }
}
//This method is called by the popover controller when the user selects a row
-(void) myCallBack:(SearchCustomer *)ff
{
    custID = ff.ID;
    [self.myPopOver dismissPopoverAnimated:YES];
    cust = [custDOA getRecords:custID];
    [self setFields];
    [self setButtons:YES];
}
This is my interface for my popover that has a searchBar controller:
@interface CustomerSearchViewController :         UITableViewController<UISearchBarDelegate>
@property (strong,nonatomic) NSMutableArray *customerSearchList;
@property (weak, nonatomic) ViewController *delegate;
@property (strong,nonatomic) NSMutableArray *resultsCustomerSearchList;
@property (weak, nonatomic) IBOutlet UISearchBar *searchBar;
@end

0 个答案:

没有答案