Play music in the background using AVAudioplayer

I had solved this question by referring iOS Application Background tasks and make some changes in .plist file of our application.. Update write this code in your controller’s view did load method like this – (void)viewDidLoad { NSURL *url = [NSURL fileURLWithPath:[[NSBundle mainBundle] pathForResource:@”in-the-storm” ofType:@”mp3″]]; AVAudioPlayer *audioPlayer = [[AVAudioPlayer alloc] initWithContentsOfURL:url error:nil]; [[AVAudioSession sharedInstance] setCategory:AVAudioSessionCategoryPlayback … Read more

Easiest way to force a crash in Swift

Typically you’d use fatalError() or preconditionFailure() for that. These do exactly the same: terminating the program, therefore the code after this stamement never gets executed. All of the functions that have this behaviour are annotated with the @noreturn attribute You can also do something like this: func getInt() -> Int { fatalError() } The function … Read more

How can I improve the performance of my custom OpenGL ES 2.0 depth texture generation?

Based on the recommendations by Tommy, Pivot, and rotoglup, I’ve implemented some optimizations which have led to a doubling of the rendering speed for the both the depth texture generation and the overall rendering pipeline in the application. First, I re-enabled the precalculated sphere depth and lighting texture that I’d used before with little effect, … Read more

What’s the difference between Camera Roll and Photo Library?

From When should I use UIImagePickerControllerSourceTypePhotoLibrary instead of UIImagePickerControllerSourceTypeSavedPhotosAlbum?: UIImagePickerControllerSourceTypePhotoLibrary references the entire photo library, letting the user choose which album. UIImagePickerControllerSourceTypeSavedPhotosAlbum goes straight to the camera roll album without giving the user a choice as to which album to choose from. They’re similar, but different. You can get to the camera roll from PhotoLibrary, … Read more

Horizontal UITableView

I have published sample code that demonstrates one approach for implementing horizontally scrolling table views using transforms. It’s called EasyTableView and provides the same interface for both vertically and horizontally scrolling table views.

Does UIGestureRecognizer work on a UIWebView?

From what I have seen, UIWebView does not play well with others. For gesture recognizers, you could try returning YES from: – (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldRecognizeSimultaneouslyWithGestureRecognizer:(UIGestureRecognizer *)otherGestureRecognizer; I had to be backwards compatible with 3.0 so I ended up doing all the gesture handling with Javascript inside the UIWebView. Not a good solution, but it worked … Read more