depicus

changing the digital world one bit at a time...

Blants (noun) the rants of a blogger

  1. ‘Invalid content size ‘ADBannerContentSizeLandscape’ passed to ADAdSizeForBannerContentSize’

    June 21, 2011 by The Man

    If you are running an iPhone app on versions lower than 4.2 you may see this error ‘Invalid content size ‘ADBannerContentSizeLandscape’ passed to ADAdSizeForBannerContentSize’

    To fix (dirty) simply set the size when the view loads.

    - (void)viewDidLoad {
        if ([[[UIDevice currentDevice] systemVersion] doubleValue] < 4.2)
        {
            adMain.requiredContentSizeIdentifiers = [NSSet setWithObject:ADBannerContentSizeIdentifier320x50];
            adMain.currentContentSizeIdentifier = ADBannerContentSizeIdentifier320x50;
        }
        [super viewDidLoad];
    }
    

  2. Android sales

    June 16, 2011 by The Man

    Just got past 100 sales. Not really selling like hot cakes but will crunch the numbers soon and see how it stacks up to iOS.

    UPDATE

    Sales figures for 8th Feb to 17th June (129 days)

    Android sales – 101

    iOS sales – 689

    So that would suggest a 6.9:1 sales ratio.


  3. Scrolling credits on iOS – how to create.

    by The Man

    Ever wanted to have scrolling credits for your iOS device ? Here is how to do it…

    Scrolling Credits from Brian Slack on Vimeo.

    1. Take your existing photo and cut out a piece as high as your UIView and as wide as your text plus a little bit.
    2. This new image will be our mask.
    3. With the mask image cut out the centre so you have a rectangle top and bottom. Clone the layer and on the first layer delete the bottom rectangle, on the other layer delete the top rectangle
    4. Add a layer mask to both.
    5. With the layer mask selected add a black/white gradient (hold down the shift key to get a straight down gradient)
    6. Your mask image is now done, add to your XCode project with the main image then the text and then the mask image on top.
    7. To animate first reset the text so it’s always in the same starting position

    lblCredits.transform = CGAffineTransformMakeTranslation(0, 0);     
    CGRect frame = lblCredits.frame;
    frame.origin.y = 550.0;
    lblCredits.frame = frame;
    

    8. Then just animate up

    [UILabel beginAnimations:nil context:NULL];
    [UILabel setAnimationDuration:30.0f];
    [UILabel setAnimationCurve:UIViewAnimationCurveLinear];
    [UILabel setAnimationBeginsFromCurrentState:YES];
    [UILabel setAnimationDelegate:self];
    [UILabel setAnimationDidStopSelector:@selector(creditsHaveEnded)];
    CGAffineTransform transform = CGAffineTransformMakeTranslation(0, -1000);
    lblCredits.transform = transform;
    [UILabel commitAnimations];
    

    9. That’s about it, dependant on how you use it you may need to cancel the animation but I’m sure you can work that out 🙂


  4. Getting EXIF data from images on iOS

    May 7, 2011 by The Man

    Working on a project that needed to show images with their information so looked into extracting EXIF data from the image itself rather than banging it into a db. Note this requires jpg files as png’s didn’t seem to work.

        NSString *myPath = [[NSBundle mainBundle] pathForResource:@"IMG_2733" ofType:@"JPG"];
        NSURL *myURL = [NSURL fileURLWithPath:myPath];
        CGImageSourceRef mySourceRef = CGImageSourceCreateWithURL((CFURLRef)myURL, NULL);
        NSDictionary *myMetadata = (NSDictionary *) CGImageSourceCopyPropertiesAtIndex(mySourceRef,0,NULL);
        NSDictionary *exifDic = [myMetadata objectForKey:(NSString *)kCGImagePropertyExifDictionary];
        NSDictionary *tiffDic = [myMetadata objectForKey:(NSString *)kCGImagePropertyTIFFDictionary];
        NSLog(@"exifDic properties: %@", myMetadata); //all data
        float rawShutterSpeed = [[exifDic objectForKey:(NSString *)kCGImagePropertyExifExposureTime] floatValue];
        int decShutterSpeed = (1 / rawShutterSpeed);
        NSLog(@"Camera %@",[tiffDic objectForKey:(NSString *)kCGImagePropertyTIFFModel]);
        NSLog(@"Focal Length %@mm",[exifDic objectForKey:(NSString *)kCGImagePropertyExifFocalLength]);
        NSLog(@"Shutter Speed %@", [NSString stringWithFormat:@"1/%d", decShutterSpeed]);
        NSLog(@"Aperture f/%@",[exifDic objectForKey:(NSString *)kCGImagePropertyExifFNumber]);
        NSNumber *ExifISOSpeed  = [[exifDic objectForKey:(NSString*)kCGImagePropertyExifISOSpeedRatings] objectAtIndex:0];
        NSLog(@"ISO %i",[ExifISOSpeed integerValue]);
        NSLog(@"Taken %@",[exifDic objectForKey:(NSString*)kCGImagePropertyExifDateTimeDigitized]);
    

    Obviously change the image name and be aware that images loaded in a UIImageView seem to have their EXIF data stripped out.


  5. Adding a UILabel to a UIToolbar the easy way…

    May 6, 2011 by The Man

    I simply quote…

    “For those using Interface Builder to layout your toolbar, it is also possible to do this using Interface Builder alone.

    To add a label to a toolbar you need to add a generic UIView object to your Toolbar in IB by dragging a new UIView object over your UIToolbar. IB will automatically create a UIBarButtonItem that will be initialized with your custom UIView. Next add a UILabel to the UIView and edit the label graphically to match your preferred style. You can then visually set up your fixed and/or variable spacers as desired to position your label appropriately.

    You must also set the background of both the UILabel and the UIView to clearColor to get the toolbar to show through correctly under the label.”

    Genius and simple. Thanks to Matt R and Stackoverflow


  6. Apples Location Services and Privacy

    April 21, 2011 by The Man

    My god there really are some complete and utter morons about. Now I appreciate keeping location data indefinitely is not ideal but please … Sky News is reporting that “…your iPhone is secretly tracking you every where you go…” yet a minute later they complain that the iPhone they tested did not track the Sky building or the users home address !!!

    Out of the many tables in the db the main two appear to be CellLocation and WifiLocation. Mmmmm ok so they record the cell location so not really where I am but the location of the cell towers that are around me. Indeed if I look at the map of these locations many are places where I don’t think I have been. So why record them ?

    Well seems that it’s all down to the battery, querying cell towers uses battery power faster than a database lookup. Now that was easy. So what’s the big issue. Well looks like the database person did their job.

    But the programmers might have cocked up a bit. The above is a trigger in the database which decreases the record count every time a record is deleted, but the records are not being deleted. Now I suspect that when they tested this feature they used a low number of days (say 1) to keep these records, then when they were happy it was working changed to a larger number. Maybe the number was so large nothing gets deleted. Or they may just have cocked up and commented out the code to delete while testing and forgot to put it back in.

    Either way while this isn’t an ideal situation it is compounded by people who know very little about the subject being dragged out to comment on the situation as experts. The situation is not helped by the misleading statements of Warden and Allan saying it is “unclear” why Apple are collecting the data. These so called “security researchers”, one who allegedly worked for Apple didn’t think of the possibility that this is data caching ?

    If you think this is bad you really aren’t going to like some of the Apps like Pandora

    UPDATE This is a very good read and much better than my ramblings http://ericfadden.com/2011/04/iphone-location-tracking-consolidated-db-and-a-rush-to-judgement/