UIButton titleLabel not displaying

You always need to specify ControlState when updating button’s title! There are four possible values for UIButtons: UIControlStateNormal UIControlStateHighlighted UIControlStateDisabled UIControlStateSelected so for example: [button setTitle:@”Title” forState:UIControlStateNormal]; and then you can set custom settings for titleLabel: [button.titleLabel setFont:[UIFont fontWithName:@”Zapfino” size:20.0]]; [button.titleLabel setTextColor:[UIColor blueColor]];

iOS Autolayout – How to set two different distances between views, depends on the screen height

You can create an NSLayoutConstraint outlet on your view controller and connect the outlet to the activity indicator’s Y constraint in your xib or storyboard. Then, add an updateViewContraints method to your view controller and update the constraint’s constant according to the screen size. Here’s an example of updateViewConstraints: – (void)updateViewConstraints { [super updateViewConstraints]; self.activityIndicatorYConstraint.constant … Read more

Undefined symbols for architecture armv7 when using ZXing library in Xcode 4.5

Well, at last I got it working.. For anyone who encounters this in the future.. Rename the main.m file to main.mm. ZXing’s README states why we need this It can happen that when trying to build your own project with ZXingWidgetController you get linker errors like “undefined reference to”. If this error looks like a … Read more

Facebook SDK 3.1 – Error validating access token

The Facebook account on the device has become out-of-sync with the server as well as with the App’s/SDK’s cache. This can be solved by calling the ACAccountStore method renewCredentialsForAccount, which will update the OS’s understanding of the token state. In the next update of the SDK, the SDK will automatically call this API when it … Read more

iOS6 UICollectionView and UIPageControl – How to get visible cell?

You must setup yourself as UIScrollViewDelegate and implement the scrollViewDidEndDecelerating:method like so: Objective-C – (void)scrollViewDidEndDecelerating:(UIScrollView *)scrollView { CGFloat pageWidth = self.collectionView.frame.size.width; self.pageControl.currentPage = self.collectionView.contentOffset.x / pageWidth; } Swift func scrollViewDidEndDecelerating(_ scrollView: UIScrollView) { let pageWidth = self.collectionView.frame.size.width pageControl.currentPage = Int(self.collectionView.contentOffset.x / pageWidth) }

Custom animation when switching from one UICollectionViewLayout to another?

#define degreesToRadians(x) (M_PI * (x) / 180.0) UICollectionView *collectionView = self.viewController.collectionView; HorizontalCollectionViewLayout *horizontalLayout = [HorizontalCollectionViewLayout new]; NSTimeInterval duration = 2; [collectionView.visibleCells enumerateObjectsUsingBlock:^(UICollectionViewCell *cell, NSUInteger index, BOOL *stop) { CABasicAnimation *rotationAnimation; rotationAnimation = [CABasicAnimation animationWithKeyPath:@”transform.rotation”]; rotationAnimation.toValue = @(degreesToRadians(360)); rotationAnimation.duration = duration; rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]; [cell.layer addAnimation:rotationAnimation forKey:@”rotationAnimation”]; }]; [UIView animateWithDuration:duration animations:^ { collectionView.collectionViewLayout = horizontalLayout; … Read more

Where to set translatesAutoresizingMaskIntoConstraints in Xcode 4.5

I’m late to this question, but the mentioned option is still missing in Xcode 5 & 6, so the question is still meaningful. Actually, we can always set a value to any property of a view/control/object by adding a User Defined Runtime Atribute in Storyboard (Interface Builder) like the following screenshot. And it also works … Read more

iOS 6 debug console gone?

I have found it helpful to output any JS errors with an alert on window.onerror -> window.onerror = function(error) { alert(error); }; I paste that into the top of scripts so that any runtime errors will be output in a native alert. Works on desktop too.

TWTweetComposeViewController deprecated in IOS6

There’re some change with using Social network between iOS 5 & iOS 6. 1. About library: in iOS 6 we use Social framework instead of Twitter Framework. 2. We use SLComposeViewController instead of TWTweetComposeViewController. 3.Please compare some api with the following code: if([SLComposeViewController isAvailableForServiceType:SLServiceTypeTwitter]) { SLComposeViewController *controller = [SLComposeViewController composeViewControllerForServiceType:SLServiceTypeTwitter]; SLComposeViewControllerCompletionHandler myBlock = ^(SLComposeViewControllerResult result){ … Read more