2016-04-14 21 views
0

私の問題は、ユーザーが重要ではない場所をクリックしたときに発生します。alertViewが呼び出されました。何度も何度も何度も何度も空いていることを示しています。しかし、幽霊警報はどこにも壊れていません誰がそれを投げているのか分かりません、ただ感情的な見方です。UIAlertViewで問題が発生しました。繰り返しソースが見つかりませんでした。

ビューがどこに呼び出されているかを特定する方法に関するヒントを教えてください。

Phantom alertView

Breakpoint never hitting that alert

EDIT: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]; 

} 

...それがすべて

+2

'UIAlertView show'メソッドのシンボリックブレークポイントを設定してみてください。 – rmaddy

+0

あなたはそれを説明できますか?どうやって? –

+1

ブレークポイントリストの左下にある+をタップします。シンボリックなブレークポイントを追加することを選択します。 ' - [UIAlertView show]'シンボルを入力してください。 – rmaddy

答えて

1

持つあなたのViewControllerを確認を貼り付けることはできませんUialertviewdelegate。

  1. あなたalertview.delegateをログ

  2. それはuialertviewdelegate関数を呼び出していないことのViewControllerのあなたのスーパークラスを確認してください。

  3. それはUIAlertControllerある場合は、チェックviewwillappear、彼らはあなたがあなたのAlertViewのコンテンツをキャッチすることができます

+0

ちょうど私がそれを得ている?または代議員であるすべてのもの? –

1

[alertviewショー]呼び出すことはありませんviewdidappear、viewwilldisappear(スーパークラスすぎ)と知り、コンテンツがまったくない場合は、提示しないでください!

これを行うには、alertViewを表示するメソッドに渡すメッセージをチェックします。

ただし、あなたのメソッドshowAreYouReadyToSubmitFormMsgが見つかりません。唯一のテストのために

+0

それは興味深いと思う。どのように私はそれをキャプチャできますか?どこに呼ばれているのかわからないのですか? –

1

:あなたはalertviewのために列挙型を取るのはなぜ

サブクラスUIAlertViewすなわち@interface MyAlertView : UIAlertView

その後MyAlertView すなわちMyAlertView *someAlert = [[MyAlertView alloc] init.......];

からUIAlertViewのすべてのインスタンスを置き換えるその後

-(void)show { 

[super show]; 

//Your breakpoint here 

OR 

NSLog([NSThread callStackSymbols]); 
} 
+0

私はそれを破った、あなたの提案のおかげで私は今それを修正している:) –

1

を上書き?表示する必要がある場合は、UIAlertViewのインスタンスを作成してください。あなたは2つの文字列パラメータalertviewマッサージとタイトルとメソッドを渡すことができる1つのメソッドを作成することができますこのタイトルとマッサージのalertviewを示しています。

+0

私のコードではない私は継承しており、大部分のために働いているここにいくつかの小さな問題があります:) –

+0

大丈夫........ :) – Lion

関連する問題