Select to view content in your preferred language

Assertion Failure in AGSMapView layoutSublayersOfLayer

3375
3
Jump to solution
03-19-2013 12:57 PM
JamesMinnihan
New Contributor
Hello all,

My ArcGIS 10.1.1 Runtime SDK for iOS project is receiving a Assertion failure inside the layoutSublayersOfLayers method. This is after completion of the viewDidLoad method inside my viewController and before the display of the map upon the iPad 6.1 emulator.

The following is returned inside Xcode's console:

2013-03-19 15:48:17.546 AFSuitability[39547:c07] In viewDidLoad 2013-03-19 15:48:17.550 AFSuitability[39547:c07] Exiting viewDidLoad... 2013-03-19 15:48:17.555 AFSuitability[39547:c07] *** Assertion failure in -[AGSMapView layoutSublayersOfLayer:], /SourceCache/UIKit_Sim/UIKit-2380.17/UIView.m:5776 2013-03-19 15:48:17.556 AFSuitability[39547:c07] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Auto Layout still required after executing -layoutSubviews. AGSMapView's implementation of -layoutSubviews needs to call super.' *** First throw call stack: (0x33a1012 0x2cbde7e 0x33a0e78 0x26e6665 0x1be539f 0x2cd16b0 0x1a3ffc0 0x1a3433c 0x1a3feaf 0x1c842bd 0x1bccb56 0x1bcb66f 0x1bcb589 0x1bca7e4 0x1bca61e 0x1bcb3d9 0x1bce2d2 0x1c7899c 0x1bc5574 0x1bc576f 0x1bc5905 0x1bce917 0x1b9296c 0x1b9394b 0x1ba4cb5 0x1ba5beb 0x1b97698 0x32fcdf9 0x32fcad0 0x3316bf5 0x3316962 0x3347bb6 0x3346f44 0x3346e1b 0x1b9317a 0x1b94ffc 0x227d 0x21a5 0x1) libc++abi.dylib: terminate called throwing an exception


For my UI at the moment, I have a simple AGSMapView set inside a iPad storyboard, with 5 standard iOS UI Buttons drawn on top of the AGSMapView:

Here's my viewController.h:

#import <UIKit/UIKit.h> #import <ArcGIS/ArcGIS.h>  @interface ASViewController : UIViewController <AGSMapViewLayerDelegate, AGSMapViewTouchDelegate> {     AGSMapView *_mapView;     AGSGraphic *_activeGraphic;     AGSSketchGraphicsLayer *_sketchLayer;     AGSGraphicsLayer *_graphicsLayer;     NSString *_currentMode;  }  @property (strong, nonatomic) IBOutlet AGSMapView *mapView; @property (strong, nonatomic) AGSGraphic *activeGraphic; @property AGSSketchGraphicsLayer *sketchLayer; @property AGSGraphicsLayer *graphicsLayer; @property (strong, retain) NSString *currentMode;  @property (weak, nonatomic) IBOutlet UIButton *trackButton; @property (weak, nonatomic) IBOutlet UIButton *lineButton; @property (weak, nonatomic) IBOutlet UIButton *rectButton; @property (weak, nonatomic) IBOutlet UIButton *polyButton; @property (weak, nonatomic) IBOutlet UIButton *circleButton;   - (IBAction)setTrackMode:(id)sender; - (IBAction)setLineMode:(id)sender; - (IBAction)setRectMode:(id)sender; - (IBAction)setPolyMode:(id)sender; - (IBAction)setCircleMode:(id)sender;   @end


and a snippet from my viewController.m:


#import "ASViewController.h"   #define kBaseMapURL @"http://services.arcgisonline.com/ArcGIS/rest/services/ESRI_StreetMap_World_2D/MapServer"  @implementation ASViewController  @synthesize activeGraphic = _activeGraphic; @synthesize mapView = _mapView; @synthesize sketchLayer = _sketchLayer; @synthesize graphicsLayer = _graphicsLayer; @synthesize currentMode = _currentMode;   - (void)viewDidLoad {     [super viewDidLoad];     NSLog(@"In viewDidLoad");     // add the base map layer for holding map tiles     NSURL *mapUrl = [NSURL URLWithString:kBaseMapURL];     AGSTiledMapServiceLayer *tiledLayer = [AGSTiledMapServiceLayer tiledMapServiceLayerWithURL:mapUrl];     [_mapView addMapLayer:tiledLayer withName:@"MapTileLayer"];          // add the graphics layer to hold all completed sketches (points, polylines, and polygons)     AGSGraphicsLayer* graphicsLayer = [AGSGraphicsLayer graphicsLayer];     [_mapView addMapLayer:graphicsLayer withName:@"GraphicsLayer"];          // add the sketch layer to hold current user sketch drawing prior to completion     AGSSketchGraphicsLayer* sketchLayer = [[AGSSketchGraphicsLayer alloc] initWithGeometry:nil];     [_mapView addMapLayer:sketchLayer withName:@"SketchLayer"];      _mapView.layerDelegate = self;          // set the ui buttons' selected states     UIImage *btnImage = [UIImage imageNamed:@"bloc.png"];     [self.trackButton setImage:btnImage forState:UIControlStateSelected];     btnImage = [UIImage imageNamed:@"bline.png"];     [self.lineButton setImage:btnImage forState:UIControlStateSelected];     btnImage = [UIImage imageNamed:@"brect.png"];     [self.rectButton setImage:btnImage forState:UIControlStateSelected];     btnImage = [UIImage imageNamed:@"bpoly.png"];     [self.polyButton setImage:btnImage forState:UIControlStateSelected];     btnImage = [UIImage imageNamed:@"bcircle.png"];     [self.circleButton setImage:btnImage forState:UIControlStateSelected];      NSLog(@"Exiting viewDidLoad...");  }
0 Kudos
1 Solution

Accepted Solutions
TomWantzenrieder
New Contributor
Hello,

I had the same error as you described here. I pointed out that for any reason (unkown to me) Xcode puts the additional element (searchBar or segmentController in my case) in the AGSMapView Element and not on the same level as the AGSMapView.

To illustrate this see figure 1 an 2 at the attachment. See Object Doc (left side) section "objects"

Figure 1 - MapView, SearchBar and SegmentController on the same level -> works fine.
[ATTACH=CONFIG]23414[/ATTACH]

Figure 2 - MapView is the parent element of SearchBar and SegmentController -> layoutSublayersOfLayer error
[ATTACH=CONFIG]23415[/ATTACH]

It's quite tricky to positioning the element on the User interface without adding them to the MapView-element. I succeed only positioning the element by the attributes. As I am new to all of this, i hope this helps you too. 😄

regards,
Tom

View solution in original post

0 Kudos
3 Replies
NimeshJarecha
Esri Regular Contributor
If possible, please post your sample Xcode project so I can try to reproduce and investigate the cause.

Regards,
Nimesh
0 Kudos
TomWantzenrieder
New Contributor
Hello,

I had the same error as you described here. I pointed out that for any reason (unkown to me) Xcode puts the additional element (searchBar or segmentController in my case) in the AGSMapView Element and not on the same level as the AGSMapView.

To illustrate this see figure 1 an 2 at the attachment. See Object Doc (left side) section "objects"

Figure 1 - MapView, SearchBar and SegmentController on the same level -> works fine.
[ATTACH=CONFIG]23414[/ATTACH]

Figure 2 - MapView is the parent element of SearchBar and SegmentController -> layoutSublayersOfLayer error
[ATTACH=CONFIG]23415[/ATTACH]

It's quite tricky to positioning the element on the User interface without adding them to the MapView-element. I succeed only positioning the element by the attributes. As I am new to all of this, i hope this helps you too. 😄

regards,
Tom
0 Kudos
Nicholas-Furness
Esri Regular Contributor
It's quite tricky to positioning the element on the User interface without adding them to the MapView-element. I succeed only positioning the element by the attributes. As I am new to all of this, i hope this helps you too. 😄


Hey Tom. Yep, this is pretty annoying Xcode behavior for me too. I've found the following have really helped me:


  • Drop new UI components into the hierarchy on the left rather than directly into the WYSIWYG editor.

  • Use the cursor keys to move the element.

  • Hold SHIFT while using the cursor keys to move the component quicker.

  • Hold OPTION while using the cursor keys to show position attributes.

  • You can drag to resize a UI component without changing its position in the hierarchy (but drag to move will).

  • COMMAND-Z is your best friend if you drop a control in the wrong spot 😄


Hope that helps too.

Cheers,

Nick.
0 Kudos