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

Why is UICollectionViewCell’s outlet nil?

I am calling self.collectionView.registerClass(LeftMenuCollectionViewCell.self, forCellWithReuseIdentifier: “ls”) again. If you are using a storyboard you don’t want to call this. It will overwrite what you have in your storyboard. If you still have the problem check wether reuseIdentifier is same in dequeueReusableCellWithReuseIdentifier and in storyboard.

How do you shrink a UIPickerView on the iPhone?

Actually, you can slightly shrink the whole UIPickerView by applying an affine transform to an enclosing view. For example: CGSize pickerSize = [pickerView sizeThatFits:CGSizeZero]; pickerTransformView = [[UIView alloc] initWithFrame:CGRectMake(0.0f, 0.0f, pickerSize.width, pickerSize.height)]; pickerTransformView.transform = CGAffineTransformMakeScale(0.75f, 0.75f); [pickerTransformView addSubview:pickerView]; [self.view addSubview:pickerTransformView]; [pickerTransformView release]; will scale a picker to 75% of its original size by placing it … Read more

UITextView with hyperlink text

Set isEditable = false or the text view will go into text-editing mode when user taps on it. Swift 4 and later let attributedString = NSMutableAttributedString(string: “Just click here to register”) let url = URL(string: “https://www.apple.com”)! // Set the ‘click here’ substring to be the link attributedString.setAttributes([.link: url], range: NSMakeRange(5, 10)) self.textView.attributedText = attributedString self.textView.isUserInteractionEnabled … Read more

How to make xib compatible with both iphone 5 and iphone 4 devices

You add new category for UIviewController and add this code in .h file – (id)initWithNibNameforIphone4:(NSString *)nibNameOrNil4 NibNameforIphone5:(NSString *)nibNameOrNil5 NibNameforIpad:(NSString *)nibNameOrNilpad bundle:(NSBundle *)nibBundleOrNil; Add this code in your .m file – (id)initWithNibNameforIphone4:(NSString *)nibNameOrNil4 NibNameforIphone5:(NSString *)nibNameOrNil5 NibNameforIpad:(NSString *)nibNameOrNilpad bundle:(NSBundle *)nibBundleOrNil { if (self = [super init]) { self = [self initWithNibName:[self CheckDeviceIphone4:nibNameOrNil4 Iphone5:nibNameOrNil5 Ipad:nibNameOrNilpad] bundle:nibBundleOrNil]; } return … Read more

Apple Interface Builder: adding subview to UIImageView

You cannot add a subview to UIImageView in interface builder for reasons only known to Apple! You are right in saying that you can addSubview programmatically, but then, the overhead of setting autoresizing masks and placements of subviews should all be handled in code, which is cumbersome. So there is an easy workaround. Instead of … Read more

@IBDesignable crashing agent

Xcode’s Interface Builder requires that you implement both or neither initializers for @IBDesignable classes to render properly in IB. If you implement required init(coder aDecoder: NSCoder) you’ll need to override init(frame: CGRect) as well, otherwise “the agent will crash” as seen in the errors thrown by Xcode. To do so add the following code to … Read more

UIButton fails to properly register touch in bottom region of iPhone screen

The cause for this issue is that Apple seems to place a GestureRecognizer at the bottom of the screen that delays touches in any other view. After fiddling around with gesture recognizers on the App’s windows I came up with a solution that incorporates a subclass of UIButton: – (BOOL)pointInside:(CGPoint)point withEvent:(UIEvent *)event { BOOL inside … Read more