Is there any way to determine if the iphone is roaming?

There is! It’s not documented at all, and I highly doubt this would work on a non-jailbroken phone (as it requires using files not in the sandbox). However, here is how it is done. The iPhone file system keeps two softlinks: static NSString *carrierPListSymLinkPath = @”/var/mobile/Library/Preferences/com.apple.carrier.plist”; static NSString *operatorPListSymLinkPath = @”/var/mobile/Library/Preferences/com.apple.operator.plist”; when these links are … Read more

how to implement lazy loading of images in table view using swift

Old Solution: Since you doesn’t show any code. Here is the example for you. func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { // try to reuse cell let cell:CustomCell = tableView.dequeueReusableCellWithIdentifier(“DealCell”) as CustomCell // get the deal image let currentImage = deals[indexPath.row].imageID let unwrappedImage = currentImage var image = self.imageCache[unwrappedImage] let imageUrl = NSURL(string: … Read more

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

Animation in OpenGL ES view freezes when UIScrollView is dragged on iPhone

Whether CADisplayLink fires during scrolls depends on the mode with which you add it to the run loop. Probably you have this, somewhere: [displayLink addToRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode]; UIApplication adds a run loop mode, UITrackingRunLoopMode, for ‘tracking in controls’, which includes when a scrollview is scrolling. So at that point the runloop is switched out of … Read more

NSDateFormatter returning nil in OS 4.0

I found out it works if you do it this way (see below). The key is using the method: – [NSDateFormatter getObjectValue:forString:range:error:] instead of -[NSDateFormatter dateFromString] The complete code: + (NSDate *)parseRFC3339Date:(NSString *)dateString { NSDateFormatter *rfc3339TimestampFormatterWithTimeZone = [[NSDateFormatter alloc] init]; [rfc3339TimestampFormatterWithTimeZone setLocale:[[[NSLocale alloc] initWithLocaleIdentifier:@”en_US_POSIX”] autorelease]]; [rfc3339TimestampFormatterWithTimeZone setDateFormat:@”yyyy-MM-dd’T’HH:mm:ssZ”]; NSDate *theDate = nil; NSError *error = nil; … 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