2016-04-14 4 views
0

Mein Problem ist dies, in der App, wenn ein Benutzer irgendwo nicht wichtig klickt ein AlertView ausgelöst wird, ist in Ordnung, ich kann den Aufruf zu dieser Ansicht finden, aber dann zeigt sich immer wieder leer und ich habe überall dort einen Haltepunkt platziert, wo ich einen Alarmruf sehe. Aber die Geisterwarnung bricht nirgendwohin. Ich habe keine Ahnung, wer sie wirft, es ist nur eine empfindsame Sichtweise.Ich habe ein Problem mit einem UIAlertView zeigt wiederholt die Quelle nicht finden

Können Sie einige Tipps geben, wie Sie den Punkt festlegen können, an dem die Ansicht aufgerufen wird?

Phantom alertView

Breakpoint never hitting that alert

EDIT:

-Code für die Viewcontroller:

#import <CoreLocation/CoreLocation.h> 
#import "FormViewController.h" 
#import "FormPageViewController.h" 
#import "FormElement+UtilityMethods.h" 
#import "UserBO.h" 
#import "RecordBO.h" 
#import "RecordAnswer.h" 
#import "UserDefaultsUtilities.h" 
#import "TimeTrackingUtilities.h" 
#import "DxColors.h" 
#import "EDQueueUtilities.h" 
#import "GroupAnswerMetadata.h" 
#import "RecordAnswer+UtilityMethods.h" 
#import "Record+UtilityMethods.h" 
#import "FormPageIndexViewController.h" 
#import "ManagedObjectUtilities.h" 
#import "EDQueue.h" 
#import "EDQueueUtilities.h" 
#import "DxAnswerObject.h" 
#import "ImageAnswerMetadata.h" 

#import "DateUtilities.h" 
#import <ifaddrs.h> 
#import "CarbonKit.h" 

#define INITIAL_CONTROLLER_INDEX 0 
#define FORM_RECORDS_TEMP_NAME @"<~TMP>" 

#define TAG_RETURN_BUTTON 0 
#define TAG_SAVE_BUTTON 1 
#define TAG_SEND_BUTTON 2 

typedef NS_ENUM(NSUInteger, AlertViewPurpose) { 
    ALERT_VIEW_FORM_NONE    = 0, 
    ALERT_VIEW_FORM_SEND_SUCCESS  = 1, 
    ALERT_VIEW_FORM_SEND_FAILURE  = 2, 
    ALERT_VIEW_FORM_SAVE_PROMPT   = 3, 
    ALERT_VIEW_FORM_FILE_NAME_PROMPT = 4, 
    ALERT_VIEW_FORM_ASYNC_SEND_SUCCESS = 5, 
    ALERT_VIEW_FORM_COULDNT_SEND  = 6, 
    ALERT_VIEW_FORM_WANT_TO_SEND  = 7, 
    ALERT_VIEW_FORM_SAVE_IN_CONTEXT_PROMPT = 8, 
    ALERT_VIEW_FORM_FILE_NAME_IN_CTXT_SAVE_PROMPT = 9, 
    ALERT_VIEW_FORM_REQUIRED_INTERNET_CONECTION = 10, 
    // Enumeration counter. 
    ALERT_VIEW_PURPOSE_COUNT 
}; 

// Based on: 
// Ref.: http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/ 

@interface FormViewController() <RecordBOProtocol, FieldElementProtocol, 
CLLocationManagerDelegate, FormPageIndexProtocol,CarbonTabSwipeNavigationDelegate> 
{ 
    AlertViewPurpose _currentAlertViewPurpose; 
    CarbonTabSwipeNavigation *_carbonTabSwipeNavigation; 
    BOOL _unedited; 
    BOOL _formRecordNilAtStartUp; 
    BOOL _timestampTaken; 

    CLLocationManager *_locationManager; 
    CLLocation *_location; 
    NSDate *_timeSpentBaseTimestamp; 
    NSArray *_sortedPages; 
    NSUInteger _currentPageIndex; 
    NSString *formID; 
    NSArray *_pagesNames; 
} 

@property (weak, nonatomic) IBOutlet UILabel *lblFormTitle; 
@property (weak, nonatomic) IBOutlet UIButton *btnSmallReturn; 
@property (weak, nonatomic) IBOutlet UIButton *btnSmallSave; 
@property (weak, nonatomic) IBOutlet UIButton *btnSmallSend; 
@property (weak, nonatomic) IBOutlet UIButton *btnBigSend; 

@property (weak, nonatomic) IBOutlet UIBarButtonItem *btnReturn; 

@property (strong, nonatomic) IBOutlet UIButton *lblBack; 
@property (strong, nonatomic) IBOutlet UIButton *lblSave; 


@end 

@implementation FormViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) { 
     // Custom initialization 
     _currentAlertViewPurpose = ALERT_VIEW_FORM_NONE; 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    [self localizedButtons]; 

    // Starting up location manager if form requires it. 
    // Ref.: 
    // https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestAlwaysAuthorization 
    if ([self.form.geolocationEnabled boolValue]) { 

     _locationManager = [[CLLocationManager alloc] init]; 
     _locationManager.delegate = self; 

     if ([CLLocationManager locationServicesEnabled]) { 

      CLAuthorizationStatus status = [CLLocationManager authorizationStatus]; 

      if (status == kCLAuthorizationStatusNotDetermined) { 
       // Requesting authorization. 
       if ([CLLocationManager instancesRespondToSelector:@selector(requestWhenInUseAuthorization)]) { 
#ifdef DEBUG_MODE 
        NSAssert(
          [[[NSBundle mainBundle] infoDictionary] valueForKey:@"NSLocationWhenInUseUsageDescription"], 
          @"For iOS 8 and above, your app must have a value for NSLocationWhenInUseUsageDescription in its Info.plist"); 
#endif // DEBUG_MODE 
        [_locationManager requestWhenInUseAuthorization]; 
       } 
      } else if (status == kCLAuthorizationStatusAuthorizedAlways || 
         status == kCLAuthorizationStatusAuthorizedWhenInUse) { 
       _locationManager.distanceFilter = kCLDistanceFilterNone; 
       _locationManager.desiredAccuracy = kCLLocationAccuracyNearestTenMeters; 
       [_locationManager startUpdatingLocation]; 
      } 
     } 
    } 

    self.lblFormTitle.text = self.form.name ; 

    // Saving whether self.formRecord was nil at beginning. 
    // Important for time spent tap calculations. 
    _formRecordNilAtStartUp = self.formRecord == nil; 

    [self setup]; 

    //Take the time for counting 
    _timeSpentBaseTimestamp = [NSDate date]; 

    _unedited = YES; 
} 

-(void)localizedButtons 
{ 
    [self.lblBack setTitle:NSLocalizedString(@"Back", @"Regresar") forState:UIControlStateNormal]; 
    [self.lblSave setTitle:NSLocalizedString(@"Save", @"Guardar") forState:UIControlStateNormal]; 
    [self.btnBigSend setTitle:NSLocalizedString(@"Send", @"Enviar") forState:UIControlStateNormal]; 
} 
- (void)didReceiveMemoryWarning 
{ 
    [super didReceiveMemoryWarning]; 
    // Dispose of any resources that can be recreated. 
} 

// Overriding from DxBaseViewController. 
-(void)refresh 
{ 
} 

-(void)setup 
{ 
    // Obtaining sorted pages array. 
    _sortedPages = [[self.form.pages allObjects] 
        sortedArrayUsingComparator:^NSComparisonResult(Page *obj1, Page * obj2) { 
         return [obj1.pageNumber compare: obj2.pageNumber]; 
        }]; 
    //Adding toolBar 
    NSMutableArray *namesPages = [[NSMutableArray alloc]init]; 

    for (Page *page in _sortedPages) { 
     NSString *namePage = page.name; 
     [namesPages addObject:namePage]; 
    } 
    _pagesNames = [namesPages copy] ; 

    // Creating by default a record in case there's none. 
    if (self.formRecord == nil) { 
     self.formRecord = [Record createInContext:self.managedObjectContext]; 
     // Filling in basic record information. 
     self.formRecord.name = FORM_RECORDS_TEMP_NAME; 
     self.formRecord.editable = self.form.editableRecords; 
     self.formRecord.dateLastSaved = self.formRecord.dateCreated = [NSDate date]; 
     self.formRecord.syncStatusId = [NSNumber numberWithInt:SYNC_STATUS_NOT_SYNCED]; 
     self.formRecord.user = [UserBO loggedInUser]; 
     self.formRecord.form = self.form; 
     self.formRecord.formId = self.form.pkey; 
     self.formRecord.temporary = [NSNumber numberWithBool:YES]; 
     self.formRecord.isBeingEdited = [NSNumber numberWithBool:YES]; 
     // Committing record information as is. It will be removed if user doesn't 
     // want to save changes. 
     if (![Record commitChangesFromContext:self.managedObjectContext]) { 
      DebugLog(@"Temp form record couldn't be saved! Check!"); 
     } 



     // Initializing page view controller. 
     _carbonTabSwipeNavigation =[[CarbonTabSwipeNavigation alloc] initWithItems:_pagesNames 
                      delegate:self]; 
     _carbonTabSwipeNavigation.toolbar.barTintColor = [DxColors colorWithHexRGB:NEW_FORMS_GREEN]; 
     [_carbonTabSwipeNavigation setNormalColor:[UIColor whiteColor]]; 
     [_carbonTabSwipeNavigation setIndicatorColor:[UIColor whiteColor]]; 
     [_carbonTabSwipeNavigation setSelectedColor:[UIColor whiteColor]]; 

    } else { 
     [self prepareControllerForEdition]; 
    } 

    [_carbonTabSwipeNavigation insertIntoRootViewController:self]; 

    self.pageViewController = _carbonTabSwipeNavigation.pageViewController; 
} 

- (UIViewController *)carbonTabSwipeNavigation:(CarbonTabSwipeNavigation *)carbontTabSwipeNavigation 
         viewControllerAtIndex:(NSUInteger)index { 

    _currentPageIndex = index; 
    // Create a new view controller and pass suitable data. 
    FormPageViewController *formPageViewController = [[FormPageViewController alloc] init]; 
    formPageViewController.pageIndex = index; 
    formPageViewController.formPage = _sortedPages[index]; 
    formPageViewController.managedObjectContext = self.managedObjectContext; 
    formPageViewController.formRecord = self.formRecord; 
    formPageViewController.observer = self; 


    formPageViewController.view.frame = CGRectMake(0, 
                0, 
                self.view.frame.size.width, 
                self.view.frame.size.height); 

    return formPageViewController; 
} 

#pragma mark - Button Actions (IBActions) 

-(IBAction)send:(id)sender 
{ 
    _timer = [NSTimer scheduledTimerWithTimeInterval:0.001 
            target:self 
            selector:@selector(isAlertViewShowing:) 
            userInfo:nil 
            repeats:YES]; 

    [self setButtonWithTag:self.btnBigSend.tag toHighlight:NO]; 

    // Disabling button to avoid double submissions. 
    self.btnBigSend.enabled = NO; 

    // Show alert. 
    [self showAreYouReadyToSubmitFormMsg]; 

} 

... kann es nicht fügen Sie alle

+2

Versuchen Sie, einen symbolischen Haltepunkt für die 'UIAlertView show'-Methode festzulegen. – rmaddy

+0

Können Sie das erklären? Wie? –

+1

Tippen Sie auf das + in der unteren linken Ecke der Breakpoint-Liste. Wählen Sie, um einen symbolischen Haltepunkt hinzuzufügen. Geben Sie das Symbol "- [UIAlertView show]" ein. – rmaddy

Antwort

1

Überprüfen Sie Ihre Viewcontroller, der hat ein ualertviewdelegate.

  1. Anmelden Ihre alertview.delegate

  2. Ihre Superklasse eines Viewcontroller Überprüfen Sie, ob es nicht uialertviewdelegate Funktion nicht nennen.

  3. Wenn es ein UIAlertController, überprüfen ViewWillAppear, ViewDidAppear, viewwilldisappear (Superklasse auch) und finden heraus, dass sie nicht nennen [Alertview show]

+0

Nur die, auf die ich das bekomme? Oder alle Delegierten? –

1

Sie den Inhalt Ihrer Alertview fangen kann, wenn es überhaupt keinen Inhalt hat, präsentiere es nicht!

Überprüfen Sie dazu die Nachricht, die Sie an die Methode übergeben, die die alertView darstellt.

Allerdings kann ich nicht finden, Ihre Methode showAreYouReadyToSubmitFormMsg.

+0

Das klingt interessant. Wie kann ich es erfassen? wenn ich nicht weiß, wo man angerufen wird? –

1

Nur zu Testzwecken:

Subclass UIAlertView dh @interface MyAlertView : UIAlertView

ersetzen dann alle Instanzen UIAlertView von MyAlertView dh MyAlertView *someAlert = [[MyAlertView alloc] init.......];

außer Kraft setzen Dann

-(void)show { 

[super show]; 

//Your breakpoint here 

OR 

NSLog([NSThread callStackSymbols]); 
} 
+0

Ich habe es kaputt gemacht, danke für deinen Vorschlag Ich muss es jetzt reparieren :) –

1

Warum Sie Enum für Alertview nehmen ? machen Sie einfach Instanz von UIAlertView, wo es erforderlich ist, zu zeigen. Sie können eine Methode machen, in der Sie zwei String-Parameter Alertview Massage und Titel und Methode Alertview mit diesem Titel und Massage übergeben können.

+0

Ist nicht mein Code, den ich geerbt habe und funktioniert ok zum größten Teil gibt es nur ein paar kleine Probleme hier und da :) –

+0

okay okay ........ :) – Lion

Verwandte Themen