Pre-buffering for AVQueuePlayer

Ok, I’ve looked over this problem again and written some code to check out AVQueuePlayer. jollyCocoa’s answer pointed me in the right direction by suggesting to observe the status property on AVPlayerItem. However the documentation doesn’t seem to point out that this property (and it’s AVPlayerItemStatusReadyToPlay value in particular) might be related to buffering. However … Read more

Which has faster performance indexesOfObjectsPassingTest or filteredArrayUsingPredicate?

The following tests (compiled in Release mode, executed on a Mac Pro) indicate that filteredArrayUsingPredicate is slower than indexesOfObjectsPassingTest if you use a “textual” predicate, but faster if you use block-based predicate. The fasted method in my test was a simple (fast-enumeration) loop that adds all matching objects to a mutable array. Results for filtering … Read more

iOS PNG Image rotated 90 degrees

For those that want a Swift solution, create an extension of UIImage and add the following method: func correctlyOrientedImage() -> UIImage { if self.imageOrientation == .up { return self } UIGraphicsBeginImageContextWithOptions(size, false, scale) draw(in: CGRect(x: 0, y: 0, width: size.width, height: size.height)) let normalizedImage = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext(); return normalizedImage ?? self; }

iOS – Scale and crop CMSampleBufferRef/CVImageBufferRef

If you use vimage you can work directly on the buffer data without converting it to any image format. outImg contains the cropped and scaled image data. The relation between outWidth and cropWidth sets the scaling. int cropX0, cropY0, cropHeight, cropWidth, outWidth, outHeight; CVImageBufferRef imageBuffer = CMSampleBufferGetImageBuffer(sampleBuffer); CVPixelBufferLockBaseAddress(imageBuffer,0); void *baseAddress = CVPixelBufferGetBaseAddress(imageBuffer); size_t bytesPerRow = … Read more

UITextView ruled line background but wrong line height

You should try and draw your lines programmatically rather than using an image. Here’s some sample code of how you could accomplish that. You can subclass UITextView and override it’s drawRect: method. NoteView.h #import <UIKit/UIKit.h> @interface NoteView : UITextView <UITextViewDelegate> { } @end NoteView.m #import “NoteView.h” @implementation NoteView – (id)initWithFrame:(CGRect)frame { self = [super initWithFrame:frame]; … Read more

Adding Navigation Bar programmatically iOS

-(void)ViewDidLoad { UINavigationBar* navbar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, 50)]; UINavigationItem* navItem = [[UINavigationItem alloc] initWithTitle:@”karthik”]; // [navbar setBarTintColor:[UIColor lightGrayColor]]; UIBarButtonItem* cancelBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemCancel target:self action:@selector(onTapCancel:)]; navItem.leftBarButtonItem = cancelBtn; UIBarButtonItem* doneBtn = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(onTapDone:)]; navItem.rightBarButtonItem = doneBtn; [navbar setItems:@[navItem]]; [self.view addSubview:navbar]; } -(void)onTapDone:(UIBarButtonItem*)item{ } -(void)onTapCancel:(UIBarButtonItem*)item{ } Swift3 let navigationBar … Read more