Categories
Computing ios iphone

Positioning UIPopoverController

The iPad has a great UI control – the UIPopoverController – most notably used in its email app when it is in portrait mode. To show, or 'present' a UIPopoverController you have two methods:

– presentPopoverFromBarButtonItem:permittedArrowDirections:animated: 
which is used to present the popover from a UIBarButton in, say, a navigation bar.

– presentPopoverFromRect:inView:permittedArrowDirections:animated:
which is used to present the popover from a location specified by a CGRect as its first parameter.

Unlike other UI controls, this CGRect actually specifies the location of the UIControl you want the popover to point at, or at least be next to. For example, the button that triggers the showing of the UIPopoverController. That is, the UIPopoverController does not use that CGRect for its own positioning – but as an 'advice' where it should be hovering.

You can also tell it where you want it to hover using the permittedArrowDirections flags, which will try to place it say, above (if the arrow direction flag is down), to the left (if the arrow direction is right), etc.

Share
Categories
ios iphone

iOS and font support: OTF, TTF, TTC

I needed to have Gill Sans Light font on the iPad. Gill Sans, in regular, bold and italic variants are native to the iPad/iPhone, but the Light is not.

I purchased the font, which to my surprise was in OTF format. The app appears to have used it without a problem. This page describes the very simple procedure of font 'installation' for your app. Other font formats that worked for me were TTF and TTC.

Share
Categories
General

SBJSON: Testing for nil / NULL value

I am playing with a variety of JSON frameworks in Objective-C. All are severely under-documented but then, they are simple to use, right? No. Nonetheless, I am deeply in awe and in debt to the great individuals who invested endless hours of their time to build these libraries and give them to us to use free of charge. Thanks you.

Anyway, SBJSON from Stig Brautaset, which I am examining right now, exposed a relatively weird issue. How do you test for null values in the contents of the parsed NSDictionary at hand? 

Plain old ([dictionary valueForKey:@"key"] == null) will not work. The breakthrough came when looking at the dictionary printout to gdb (Right-click the object in memory and select 'Print Description to Console'). The null value was 'stored' in a CFNull reference. To test whether a pointer is pointing at CFNull, you do this:

myVariable == kCFNull where kCFNull is a special memory address dedicated to hold this special null (nil!) value. 

Share
Share