Does anyone know what the new Exit icon is used for when editing storyboards using Xcode 4.5?

I had a hard time following the accepted answer so here is more detail. Given the photo below on view controller C you can “exit” back to any view controller in the segue path. ViewController A you can write: – (IBAction)done:(UIStoryboardSegue *)segue { // Optional place to read data from closing controller } ViewController B … Read more

Custom Font Sizing in Xcode 6 Size Classes not working properly with Custom Fonts

Fast fix: 1) Set fonts as System for size classes 2) Subclass UILabel and override “layoutSubviews” method like: – (void)layoutSubviews { [super layoutSubviews]; // Implement font logic depending on screen size if ([self.font.fontName rangeOfString:@”bold” options:NSCaseInsensitiveSearch].location == NSNotFound) { NSLog(@”font is not bold”); self.font = [UIFont fontWithName:@”Custom regular Font” size:self.font.pointSize]; } else { NSLog(@”font is bold”); … Read more

Can I disable autolayout for a specific subview at runtime?

I had the same problem. But I have resolved it. Yes, you can disable auto layout at runtime for a specific UIView, instead of disabling it for the whole xib or storyboard which is set by default in Xcode 4.3 and later. Set translatesAutoresizingMaskIntoConstraints to YES, before you set the frame of your subview: self.exampleView.translatesAutoresizingMaskIntoConstraints … Read more

What is a StoryBoard ID and how can I use this?

The storyboard ID is a String field that you can use to create a new ViewController based on that storyboard ViewController. An example use would be from any ViewController: //Maybe make a button that when clicked calls this method – (IBAction)buttonPressed:(id)sender { MyCustomViewController *vc = [self.storyboard instantiateViewControllerWithIdentifier:@”MyViewController”]; [self presentViewController:vc animated:YES completion:nil]; } This will create … Read more

How to add a button to UINavigationBar?

Sample code to set the rightbutton on a NavigationBar. UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@”Done” style:UIBarButtonItemStyleDone target:nil action:nil]; UINavigationItem *item = [[UINavigationItem alloc] initWithTitle:@”Title”]; item.rightBarButtonItem = rightButton; item.hidesBackButton = YES; [bar pushNavigationItem:item animated:NO]; But normally you would have a NavigationController, enabling you to write: UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@”Done” style:UIBarButtonItemStyleDone target:nil action:nil]; self.navigationItem.rightBarButtonItem = … Read more

Xcode 6 Storyboard the wrong size?

Do the following steps to resolve the issue In Storyboard, select any view, then go to the File inspector. Uncheck the “Use Size Classes”, you will ask to keep size class data for: iPhone/iPad. And then Click the “Disable Size Classes” button. Doing this will make the storyboard’s view size with selected device.

How to make UIButton’s text alignment center? Using IB

This will make exactly what you were expecting: Objective-C: [myButton.titleLabel setTextAlignment:UITextAlignmentCenter]; For iOS 6 or higher it’s [myButton.titleLabel setTextAlignment: NSTextAlignmentCenter]; as explained in tyler53’s answer Swift: myButton.titleLabel?.textAlignment = NSTextAlignment.Center Swift 4.x and above myButton.titleLabel?.textAlignment = .center