Print PDF
Interface Builder Elements

Rotating UIPickerView between landscape and portrait orientations

One of the UI improvements in the first update of Niftybean's index cards app iSpeechCards is support for both landscape and portrait orientation when editing card content.  When editing a card's duration there's a custom UIPickerView displaying hours and minutes.  This picker is positioned at the bottom of the screen and also scales and stretches in landscape.

Here's the simplest way I've been able to achieve this using Interface Builder layout and minimal code in the view controller. For this example I'm using a UIDatePicker but any UIPickerView will work.

The quick solution

Use this quick solution if you don't mind the UIPickerView height staying at the default 216 px.

  1. Create the elements and hook them into your code using IBOutlet
  2. Support both orientations in the view controller.
  3. Adjust the resizing mask in viewDidLoad:
Read more...
 

Core Data and ordered reflexive relationships

Print PDF
Core Data Test Model

I recently implemented an ordered, reflexive relationship in core data - similar to the many-to-many Friend example in the Core Data Programming Guide. In that example there is the main Person table, and a join entity called FriendInfo which also has a ranking attribute.

In my use case the join entity has a 'type' and I needed Core Data to efficiently select related entities by type and order. To explore the performance and see what core data actually does I created a small model and tried several approaches to fetching, using SQL debug logging to dump the queries. I ran a release build on my iPhone 3G device to capture the logging and aggregated logs into a spreadsheet to summarize run times.

Read more...
   

Selecting regions from rotated EXIF images on iPhone

Print PDF
Original sample images

This article summarizes the general problem of programmatically selecting a region from an iPhone image that may be rotated (i.e. has an embedded EXIF orientation tag) and my solution.

Some Objective-C iPhone code I've been writing recently needed to extract a region of the original UIImage provided to UIImagePickerControllerDelegates. If you've used this controller you'll know that when using a UIImagePickerController to select an image source, the full original image and optionally a selected region is returned (assuming the user didn't cancel). The nice thing about the selected region is that it is already oriented vertically in relation to how it appears on-screen.

In contrast, the full image is not rotated but still contains EXIF rotation data, which is made available to your code via the UIImage.orientation property. This is where you have to manage your selection rects properly.

Read more...
   
  • «
  •  Start 
  •  Prev 
  •  1 
  •  2 
  •  Next 
  •  End 
  • »

View in the App Store

Niftybean Blog


Subscribe

Contact Us

Contact Us

Email us or reach us using details below

  • Address:
    PO Box 11463, Manners St Central, Wellington
  • Tel:
    (64)-4-550-3887


NZiPhone.com

iphonewzealand.co.nz

Search site

Login