As you probably already know, sending push notification from Firebase will not display attached image on device. This example assumes you know how to configure push notifications in your app with Firebase. So let’s start.Continue reading
Tag: xcode
IBOutlet becomes nil in viewDidLoad function of your UIViewController?
This is a bit scary for all beginners. You made your pretty view in Interface Builder, attached UIViewController and trying to:
1 2 |
let vc = new MyNewController() self.present(vc, animated: true, completion: nil) |
Using Swift with Objective-C in framework project
I’m pretty sure there are lot of tutorials about mixing ObjectiveC with Swift in both ways. But most of them are covering only normal projects. If you have framework in which you need to mix both languages, you cannot create simple bridging header because you will hit “using bridging headers with framework targets is unsupported” error. What to do then?Continue reading
How to use JSContext from JavaScriptCore to create two way communication with web page
What is “JavaScriptCore”? Well, it is a name for internal Safari javascript engine. Is it useful? For most of us it is not, but if you thinking about communicating between your Swift app and web page, it can be really useful.
Continue reading
Fatal error: unexpectedly found nil while unwrapping an Optional value
This can be really painful when you just started with Swift. It really happens very often and can be confusing. Where it comes from?Continue reading
Jenkins & XCode: User interaction is not allowed when executing task
Getting “User interaction is not allowed” error in your build task? If yes, solution is very simple. Just login your build user (usually “jenkins”) via the GUI (which means VNC) and open Keychain Access. Select your signing private key, right-click, choose Get Info, change to the Access Control tab and select the “Allow all applications to access this item”.
Now error should be gone.
UINavigationItem back button in UIViewController hell
Sooner or later you will face with changing back button title in navigation bar. This may seem simple. But after few hours trying to change this damn text, you will change your mind. I have no idea why this is designed this way, but answer for question “How can I change back button text in current view controller?” is – you cannot. So how to do it without overriding whole navigation bar? All you have to do is change title of backBarButtonItem in PREVIOUS view controller. But there is another catch – you can’t just do :
self.navigationItem.backBarButtonItem.title = @""
becouse this won’t work. Instead of this, you need to:
UIBarButtonItem* backBarButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"" style:UIBarButtonItemStylePlain target:nil action:nil]; self.navigationItem.backBarButtonItem = backBarButtonItem;
And keep in mind – this has to be done in PREVIOUS controller, not the one you need to change your back button text. The alternative is to give up on native back button and create your own with:
UIBarButtonItem *backButton = [[UIBarButtonItem alloc] initWithTitle:@"My back button" style:UIBarButtonItemStylePlain target:nil action:nil]; self.navigationItem.hidesBackButton = YES; self.navigationItem.leftBarButtonItem = backButton;
How to proper use UIImage with tint color?
This can seem trivial, but I saw lot of people complaining about not working tint color when using UIImage. Here is the proper way:
UIImageView *imageView = [[UIImageView alloc] init]; UIImage *image = [UIImage imageNamed:@"my_image"]; imageView.image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysTemplate]; [imageView setTintColor:[UIColor redColor]];
The point is – “imageWithRenderingMode” method just returns new image with rendering mode set, it does not changes anything in image object itself.
Sharing data between UIViewControllers
If you are new to iOS programming this may take you a while to found out. But I’m here to help so will give you ready to use solution. So you have two (or more) view controllers (UIViewController) and one of them should show list of items, second one details of selected item? Well, solution depends on the way you are doing transitions betweeen controllers.
Apple TV 4th gen is not recognized by iTunes 12.3?
Lot of people have same problem – they received developer kit, connected via USB-C to Mac and iTunes shows nothing. I saw lot of solutions, but only one of them is working. So what to do to make your brand new Apple TV visible in iTunes? Answer is… nothing. You can’t. It won’t yet recognize it. If you need to get UDID, just use XCode Devices (from XCode 7.1, not 7.0!) and you can get it easily. So far iTunes doesn’t seems to support new Apple TV yet.