title: Displaying a popover crashes my iOS 8 app
body: <p>A single popover that is called from multiple different view controllers without a problem except for one particular view controller. All the view controllers descend from the same parent class and thus use the same function to display the popover. The function uses <code>presentPopoverFromRect</code>to display the popover in question. On the problem view controller I can see the popover's <code>viewDidLoad</code>fire then the app crashes with a invalid argument exception. I have no idea what UILabel its talking about or why its trying to get its length.</p>
  
  <pre><code>-(IBAction) showNormSelector:(id)sender
  {
      if (self.normSelectionPopover == nil)
      {
          Ace_Metrix_iPad_2AppDelegate *appDelegate = [[UIApplication sharedApplication] delegate];
          UIStoryboard* storyBoard = [UIStoryboard storyboardWithName:@"AceMetrixMOBILEHD_Storyboard" bundle:[NSBundle mainBundle]];
          NSMutableDictionary* mdic = [[NSMutableDictionary alloc]initWithCapacity:4];
  
          mdic[NSLocalizedStringFromTable(@"Industry", appDelegate.stringTableName,@"")] = @(IndustryType);
          mdic[NSLocalizedStringFromTable(@"Category", appDelegate.stringTableName,@"")] = @(CategoryType);
          mdic[NSLocalizedStringFromTable(@"Subcategory", appDelegate.stringTableName,@"")] = @(SubCategoryType);
          mdic[NSLocalizedStringFromTable(@"Brand", appDelegate.stringTableName,@"")] = @(BrandType);
  
          NSArray* arr = @[NSLocalizedStringFromTable(@"Industry", appDelegate.stringTableName,@""),
                           NSLocalizedStringFromTable(@"Category", appDelegate.stringTableName,@""),
                           NSLocalizedStringFromTable(@"Subcategory", appDelegate.stringTableName,@""),
                           NSLocalizedStringFromTable(@"Brand", appDelegate.stringTableName,@"")];
  
          self.popOver = (SelectorPopover*)[storyBoard instantiateViewControllerWithIdentifier:@"NormTypeSelector"];
          [self.popOver setSelectionText:mdic];
          [self.popOver setAllKeys:[NSMutableArray arrayWithArray:arr]];
          [self.popOver setDelegate:self];
  
          self.normSelectionPopover = [[UIPopoverController alloc] initWithContentViewController:self.popOver];
      }
  
      [self.popOver setCurrentSel:@(self.normType)];
      [self.popOver.tableView reloadData];
  
      [self.normSelectionPopover presentPopoverFromRect:self.normButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionUp  animated:YES];
  }
  </code></pre>
  
  <p>SelectorPopover.m</p>
  
  <pre><code>@implementation SelectorPopover
  
  @synthesize delegate;
  @synthesize selectionText;
  @synthesize allKeys;
  @synthesize tag;
  @synthesize currentSel;
  
  -(void) viewDidLoad {
      [super viewDidLoad];
  
      self.clearsSelectionOnViewWillAppear = NO;
  
      if ([[[UIDevice currentDevice] systemVersion] floatValue] &lt; 7)  //  before iOS 7
      {
          self.contentSizeForViewInPopover = CGSizeMake(135, [self.tableView rowHeight] * 4);  // Depricated in iOS 7
      }
      else
      {
          self.preferredContentSize = CGSizeMake(135, [self.tableView rowHeight] * 4);
      }
  
      NSUInteger newIndex[] = {0, 0};
      NSIndexPath* indexPath = [[NSIndexPath alloc] initWithIndexes:newIndex length:2];
      [self.tableView selectRowAtIndexPath:indexPath animated:NO scrollPosition: UITableViewScrollPositionNone];
  }
  
  
  /*
   -(void) viewWillAppear:(BOOL)animated {
   [super viewWillAppear:animated];
   }
   */
  /*
   -(void) viewDidAppear:(BOOL)animated {
   [super viewDidAppear:animated];
   }
   */
  /*
   -(void) viewWillDisappear:(BOOL)animated {
   [super viewWillDisappear:animated];
   }
   */
  /*
   -(void) viewDidDisappear:(BOOL)animated {
   [super viewDidDisappear:animated];
   }
   */
  
  
  - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation  // Deprecated in iOS6
  {
      if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft ||  interfaceOrientation == UIInterfaceOrientationLandscapeRight)
          return YES;
  
      return NO;
  }
  
  - (NSUInteger)supportedInterfaceOrientations
  {
      return UIInterfaceOrientationMaskLandscape;
  }
  
  #pragma mark -
  #pragma mark Table view data source
  
  - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
      // Return the number of sections.
      return 1;
  }
  
  
  - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
      // Return the number of rows in the section.
      return [self.selectionText count];
  }
  
  
  // Customize the appearance of table view cells.
  - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
  
      static NSString *CellIdentifier = @"SelectCell";
  
      UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
      if (cell == nil) {
          cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
      }
  
      cell.selectionStyle = UITableViewCellSelectionStyleNone;
  
      NSString* method = self.allKeys[indexPath.row];
      cell.textLabel.text = method;
      [cell.textLabel setTextColor:AMColorNeutralMidGrey38];
      cell.accessoryType = UITableViewCellAccessoryNone;
      cell.accessoryView = nil;
  
      NSNumber* uuid = (self.selectionText)[method];
  
      if ([self.currentSel integerValue] == [uuid integerValue])
      {
          UIImageView *checkmark = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"checkmark_blue.png"]];
          cell.accessoryView = checkmark;
  
          [cell.textLabel setTextColor:AMColorTradeMarkLightBlue];
          cell.accessoryType = UITableViewCellAccessoryCheckmark;
      }
  
      return cell;
  }
  
  
  /*
   // Override to support conditional editing of the table view.
   - (BOOL)tableView:(UITableView *)tableView canEditRowAtIndexPath:(NSIndexPath *)indexPath {
   // Return NO if you do not want the specified item to be editable.
   return YES;
   }
   */
  
  
  /*
   // Override to support editing the table view.
   -(void) tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath {
  
   if (editingStyle == UITableViewCellEditingStyleDelete) {
   // Delete the row from the data source.
   [tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationFade];
   }
   else if (editingStyle == UITableViewCellEditingStyleInsert) {
   // Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view.
   }
   }
   */
  
  
  /*
   // Override to support rearranging the table view.
   -(void) tableView:(UITableView *)tableView moveRowAtIndexPath:(NSIndexPath *)fromIndexPath toIndexPath:(NSIndexPath *)toIndexPath {
   }
   */
  
  
  /*
   // Override to support conditional rearranging of the table view.
   - (BOOL)tableView:(UITableView *)tableView canMoveRowAtIndexPath:(NSIndexPath *)indexPath {
   // Return NO if you do not want the item to be re-orderable.
   return YES;
   }
   */
  
  
  #pragma mark -
  #pragma mark Table view delegate
  
  -(void) tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
      if (self.delegate)
      {
          NSString* key = self.allKeys[indexPath.row];
  
          NSNumber* value = (NSNumber*) (self.selectionText)[key];
  
          [self.delegate itemSelected:[value integerValue]];
      }
  }
  
  
  #pragma mark -
  #pragma mark Memory management
  
  -(void) didReceiveMemoryWarning {
      // Releases the view if it doesn't have a superview.
      [super didReceiveMemoryWarning];
  
      // Relinquish ownership any cached data, images, etc. that aren't in use.
  }
  
  -(void) viewDidUnload {
      // Relinquish ownership of anything that can be recreated in viewDidLoad or on demand.
          [super viewDidUnload];
  }
  
  
  -(void) dealloc {
      self.delegate = nil;
  }
  
  @end
  </code></pre>
  
  <p>SelectorPopover.h</p>
  
  <pre><code>@protocol ItemSelectdDelegate
  
  -(void)itemSelected:(HierarchyType) item;
  
  @end
  
  @interface SelectorPopover : UITableViewController 
  
  @property (nonatomic, weak) id&lt;ItemSelectdDelegate&gt; delegate;
  @property (nonatomic,strong) NSMutableDictionary* selectionText;
  @property (nonatomic,strong) NSMutableArray* allKeys;
  @property (nonatomic,strong) NSNumber* currentSel;
  
  @property (nonatomic) NSInteger tag;
  
  @end
  </code></pre>
  
  <p>Call Stack:</p>
  
  <pre><code>*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UILabel length]: unrecognized selector sent to instance 0x7b60bd30'
  *** First throw call stack:
  (
      0   CoreFoundation                      0x03b49df6 __exceptionPreprocess + 182
      1   libobjc.A.dylib                     0x02f52a97 objc_exception_throw + 44
      2   CoreFoundation                      0x03b51a75 -[NSObject(NSObject) doesNotRecognizeSelector:] + 277
      3   CoreFoundation                      0x03a9a9c7 ___forwarding___ + 1047
      4   CoreFoundation                      0x03a9a58e _CF_forwarding_prep_0 + 14
      5   CoreFoundation                      0x03a33306 CFStringAppend + 374
      6   CoreFoundation                      0x03a30e2a __CFStringAppendFormatCore + 11754
      7   CoreFoundation                      0x03b26aa5 _CFStringCreateWithFormatAndArgumentsAux2 + 245
      8   Foundation                          0x004e9377 -[NSPlaceholderString initWithFormat:locale:arguments:] + 159
      9   Foundation                          0x004ecc22 +[NSString stringWithFormat:] + 89
      10  UIKit                               0x00aaa7a4 -[UIViewController _presentViewController:withAnimationController:completion:] + 2825
      11  UIKit                               0x00aad032 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 345
      12  UIKit                               0x00aace84 -[UIViewController presentViewController:animated:completion:] + 224
      13  UIKit                               0x01019011 -[UIPopoverController _presentShimmedPopoverFromRect:inView:permittedArrowDirections:animated:] + 217
      14  UIKit                               0x01019211 -[UIPopoverController presentPopoverFromRect:inView:permittedArrowDirections:animated:] + 355
      15  Ace Metrix MOBILE HD                0x00111242 -[AdDetailViewController showNormSelector:] + 3762
      16  libobjc.A.dylib                     0x02f687cd -[NSObject performSelector:withObject:withObject:] + 84
      17  UIKit                               0x0094779d -[UIApplication sendAction:to:from:forEvent:] + 99
      18  UIKit                               0x0094772f -[UIApplication sendAction:toTarget:fromSender:forEvent:] + 64
      19  UIKit                               0x00a7aa16 -[UIControl sendAction:to:forEvent:] + 69
      20  UIKit                               0x00a7ae33 -[UIControl _sendActionsForEvents:withEvent:] + 598
      21  UIKit                               0x00a7a09d -[UIControl touchesEnded:withEvent:] + 660
      22  UIKit                               0x00d7e257 _UIGestureRecognizerUpdate + 13225
      23  UIKit                               0x0099771b -[UIWindow _sendGesturesForEvent:] + 1356
      24  UIKit                               0x0099857f -[UIWindow sendEvent:] + 769
      25  UIKit                               0x0095daa9 -[UIApplication sendEvent:] + 242
      26  UIKit                               0x0096d8de _UIApplicationHandleEventFromQueueEvent + 20690
      27  UIKit                               0x00942079 _UIApplicationHandleEventQueue + 2206
      28  CoreFoundation                      0x03a6d7bf __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
      29  CoreFoundation                      0x03a632cd __CFRunLoopDoSources0 + 253
      30  CoreFoundation                      0x03a62828 __CFRunLoopRun + 952
      31  CoreFoundation                      0x03a621ab CFRunLoopRunSpecific + 443
      32  CoreFoundation                      0x03a61fdb CFRunLoopRunInMode + 123
      33  GraphicsServices                    0x04b5a24f GSEventRunModal + 192
      34  GraphicsServices                    0x04b5a08c GSEventRun + 104
      35  UIKit                               0x00945e16 UIApplicationMain + 1526
      36  Ace Metrix MOBILE HD                0x00006cad main + 141
      37  libdyld.dylib                       0x03541ac9 start + 1
  )
  libc++abi.dylib: terminating with uncaught exception of type NSException
  </code></pre>