Ios 我对UIAlertView反复显示can';我找不到源头
我的问题是,在应用程序中,当用户单击某个不重要的位置时,会引发一个alertView(没问题),我可以找到对该视图的调用,但随后会一次又一次地显示为空,我在看到任何警报调用的任何地方都放置了断点。但是幽灵警报没有被打破我不知道是谁在扔它只是一个有知觉的观点 您能否提供一些有关如何确定视图调用位置的提示 编辑: viewController的代码:Ios 我对UIAlertView反复显示can';我找不到源头,ios,objective-c,xcode,uialertview,Ios,Objective C,Xcode,Uialertview,我的问题是,在应用程序中,当用户单击某个不重要的位置时,会引发一个alertView(没问题),我可以找到对该视图的调用,但随后会一次又一次地显示为空,我在看到任何警报调用的任何地方都放置了断点。但是幽灵警报没有被打破我不知道是谁在扔它只是一个有知觉的观点 您能否提供一些有关如何确定视图调用位置的提示 编辑: viewController的代码: #import <CoreLocation/CoreLocation.h> #import "FormViewController.h
#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];
}
#导入
#导入“FormViewController.h”
#导入“FormPageViewController.h”
#导入“FormElement+UtilityMethods.h”
#导入“UserBO.h”
#导入“RecordBO.h”
#导入“RecordAnswer.h”
#导入“UserDefaultsUtilities.h”
#导入“TimeTrackingUtilities.h”
#导入“DxColors.h”
#导入“EDQueueUtilities.h”
#导入“GroupAnswerMetadata.h”
#导入“RecordAnswer+UtilityMethods.h”
#导入“记录+实用方法.h”
#导入“FormPageIndexViewController.h”
#导入“ManagedObjectUtilities.h”
#导入“EDQueue.h”
#导入“EDQueueUtilities.h”
#导入“DxAnswerObject.h”
#导入“ImageAnswerMetadata.h”
#导入“DateUtilities.h”
#进口
#进口“CarbonKit.h”
#定义初始\u控制器\u索引0
#定义表单\记录\临时\名称@“”
#定义标记返回按钮0
#定义标记\保存\按钮1
#定义标记发送按钮2
typedef NS_枚举(NSInteger,AlertViewPurpose){
警报\u视图\u表单\u无=0,
警报\查看\表单\发送\成功=1,
警报\查看\表单\发送\失败=2,
警报\查看\表单\保存\提示=3,
警报\视图\表单\文件\名称\提示=4,
警报\查看\表单\异步\发送\成功=5,
警报\u查看\u表单\u无法\u发送=6,
警报\u查看\u表单\u希望\u发送=7,
警报\u视图\u表单\u在\u上下文中保存\u提示=8,
警报\u视图\u表单\u文件\u名称\u在\u CTXT\u SAVE\u提示符=9,
警报\u视图\u表单\u必需\u互联网连接=10,
//枚举计数器。
警报\查看\目的\计数
};
//基于:
//参考号:http://www.appcoda.com/uipageviewcontroller-storyboard-tutorial/
@接口FormViewController()
{
AlertViewPurpose\u currentAlertViewPurpose;
碳塔板活化*\u碳塔板活化;
BOOL_未经编辑;
BOOL_formRecordNilAtStartUp;
布尔(BOOL);;
CLLocationManager*_locationManager;
CLLocation*\u位置;
NSDate*_timeSpentBaseTimestamp;
NSArray*_分拣页;
NSUInteger\u currentPageIndex;
NSString*formID;
NSArray*_pagesNames;
}
@性质(弱、非原子)IBUILabel*lblFormTitle;
@属性(弱,非原子)IBUIButton*btnSmallReturn;
@属性(弱、非原子)IBUIButton*btnSmallSave;
@属性(弱、非原子)IBUIButton*btnSmallSend;
@属性(弱、非原子)IBUIButton*btnBigSend;
@性质(弱、非原子)IBUIBarbuttonite*btnReturn;
@属性(强,非原子)IBUIButton*lblBack;
@属性(强,非原子)IBUIButton*lblSave;
@结束
@FormViewController的实现
-(id)initWithNibName:(NSString*)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil
{
self=[super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
如果(自我){
//自定义初始化
_currentAlertViewPurpose=ALERT\u VIEW\u FORM\u NONE;
}
回归自我;
}
-(无效)viewDidLoad
{
[超级视图下载];
[自定位按钮];
//如果表单需要,请启动位置管理器。
//参考号:
// https://developer.apple.com/library/ios/documentation/CoreLocation/Reference/CLLocationManager_Class/index.html#//apple_ref/occ/instm/CLLocationManager/requestAlwaysAuthorization
if([self.form.geolocationEnabled布尔值]){
_locationManager=[[CLLocationManager alloc]init];
_locationManager.delegate=self;
如果([CLLocationManager LocationServiceEnabled]){
CLAuthorizationStatus=[CLLocationManager授权状态];
如果(状态==kCLAuthorizationStatusNotDetermined){
//请求授权。
if([CLLocationManager实例响应选择器:@selector(RequestWhenUseAuthorization)]){
#ifdef调试_模式
恩萨塞特(
[[[NSBundle mainBundle]信息字典]valueForKey:@“NSLocationWhenInUsageDescription”],
@“对于iOS 8及以上版本,您的应用程序在其Info.plist中必须具有nsLocationWhenUsageDescription的值”);
#endif//DEBUG_模式
[_locationManager请求使用授权];
}
}else if(状态==KClauthorizationStatusAuthorizationDalways||
状态==kCLAuthorizationStatusAuthorizedWhenInUse){
_locationManager.distanceFilter=KCLDistanceFilterOne;
_locationManager.desiredAccuracy=KCallocationAccuracyNearesttenmeters;
[_LocationManagerStartupDatingLocation];
}
}
}
self.lblFormTitle.text=self.form.name;
//正在保存self.formRecord在开始时是否为零。
//重要的是用于抽头计算的时间。
_formRecordNilAtStartUp=self.formRecord==nil;
[自我设置];
//花点时间数数
_TimesPentBaseTimstamp=[NSDate日期];
_未编辑=是;
}
-(无效)本地化按钮
{
[self.lblBack setTitle:NSLocalizedString(@“Back”,@“Regresar”)用于状态:UIControlStateNormal];
[self.lblSave setTitle:NSLocalizedString(@“Save”,@“Guardar”)用于状态:UIControlStateNormal];
[self.btnBigSend setTitle:NSLocalizedString(@“发送”,@“环境”)用于状态:UIControlStateNormal];
}
-(无效)未收到记忆警告
{
[超级记忆警告];
//处置所有可以重新创建的资源。
}
//从DxBaseViewController重写。
-(无效)刷新
{
}
-(无效)设置
{
//获取排序页面数组。
_sortedPages=[[self.form.pages allObjects]
罗非鱼素
-(void)show {
[super show];
//Your breakpoint here
OR
NSLog([NSThread callStackSymbols]);
}