force landscape ios 7

Here is how I forced one of my views to be Landscape using NavigationViewController: Implemented this answer: https://stackoverflow.com/a/12662433/2394787 Imported message in the View controller: objc/message.h Added this line of code in the viewDidLoad method: objc_msgSend([UIDevice currentDevice], @selector(setOrientation:), UIInterfaceOrientationLandscapeLeft); Hope it helps someone.

Differentiate between screen lock and home button press on iOS7

This can help you both on iOS6 & iOS7 :). When user press lock button you will get a com.apple.springboard.lockcomplete notification. //new way //put this in – (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions CFNotificationCenterAddObserver(CFNotificationCenterGetDarwinNotifyCenter(), NULL, displayStatusChanged, CFSTR(“com.apple.springboard.lockcomplete”), NULL, CFNotificationSuspensionBehaviorDeliverImmediately); //put this function in AppDelegate static void displayStatusChanged(CFNotificationCenterRef center, void *observer, CFStringRef name, const void *object, CFDictionaryRef userInfo) … Read more

iOS7 – receipts not validating at sandbox – error 21002 (java.lang.IllegalArgumentException)

I’ve had this problem and looked everywhere, including on Apple’s development forums. Apple will give a couple of stock replies, and that’s it. I think it’s a bug on Apple’s side. Validation locally on the device will work, so try to convert to that. If you absolutely must use server side validation, only transactionReceipt seems … Read more

How to add CSS for HTML to NSAttributedString?

Since iOS 7 you can use NSAttributedString with HTML syntax: NSURL *htmlString = [[NSBundle mainBundle] URLForResource: @”string” withExtension:@”html”]; NSAttributedString *stringWithHTMLAttributes = [[NSAttributedString alloc] initWithFileURL:htmlString options:@{NSDocumentTypeDocumentAttribute:NSHTMLTextDocumentType} documentAttributes:nil error:nil]; textView.attributedText = stringWithHTMLAttributes; // attributedText field! You have to add string.html to you project, and the content of the html can be like this: <html> <head> <style type=”text/css”> … Read more

Zooming and scrolling in SpriteKit

Here is my solution to the scrolling problem. It revolves around “stealing” the behaviour from the UIScrollView. I learned this from a WWDC Video from 2012 about mixing UIKit with OpenGL. Add the UIScrollViewDelegate methods to your ViewController and set the scroll view delegate to the ViewController Add/Move the PanGestureRecognizer from the UIScrollView to the … Read more

UIScrollView doesn’t scroll after upgrading to iOS7 / xcode 5

I solved this by deselecting ‘Use Autolayout’ in the File Inspector pane of main view within the Scroll View. If you want to keep ‘Autolayout’ enabled, try ‘Editor -> Reslove Autolayout Issues -> Add Missing Constraints’. The key constraint appears to be ‘Bottom Space to: Superview and in my case was -300, giving 300 scroll … Read more

Multiple select in Safari iOS 7

// hack for iPhone 7.0.3 multiselects bug if(navigator.userAgent.match(/iPhone/i)) { $(‘select[multiple]’).each(function(){ var select = $(this).on({ “focusout”: function(){ var values = select.val() || []; setTimeout(function(){ select.val(values.length ? values : [”]).change(); }, 1000); } }); var firstOption = ‘<option value=”” disabled=”disabled”‘; firstOption += (select.val() || []).length > 0 ? ” : ‘ selected=”selected”‘; firstOption += ‘>&laquo; Select ‘ … Read more