Blog

Headnix — Clip It!

Monday, Jun 13, 2011 UIPopoverController and device orientation

You are required to take care of your own popover’s behavior when device orientation change. This is true when you present the popover using presentPopoverFromRect:inView:permittedArrowDirections:animated:.

“… if you presented the popover from a target rectangle in a view, the popover controller does not attempt to reposition the popover. In those cases, you must manually hide the popover or present it again from an appropriate new position. You can do this in the didRotateFromInterfaceOrientation: method of the view controller that you used to present the popover.” Please refer back to iOS documentation for detail.

Don’t forget that UIPopoverController is not a subclass of UIViewController in iOS 4 too.

Tuesday, May 24, 2011 Tips to those using text view and keyboard in iOS

When you have a long input form in your iOS app, you probably should pay attention to position of the text input fields when user taps of them. The software keyboard may cover those elements.

If you are housing the text input fields in UITableView, good news for you. iOS UITableView will make sure text input field in focus is not hidden by the software keyboard. However, if you implement your own scrollview, you have to handle that yourself.

Apple offers a great document on this matter – Moving Content That Is Located Under the Keyboard. I have a few things to add to complement the documentation…

  • If you listen to keyboard notification and implement text view delegate methods as well, the keyboard notification is actually called after the those text view “should” and “did” begin edit. And, in another runloop cycle.
  • You will receive keyboard notification more than once (within the same text view being and did end edit session)! When user switches input method of the keyboard, the keyboard notifications are fired.

Some asian language keyboards for reference:

Chinese pinyi iPad Chinese Pinyi Keyboard

Japanese fifty key iPad Japanese Keyboard

You can download my test code to understand the behavior better – TextViewEditUX.zip 656KB.

Friday, Jan 07, 2011 Clip It! now available in Mac App Store

Clip It! in Mac App Store

We are excited to be one of the Mac App Store launching apps. Clip It! allows you to capture web pages in one single image. It is the tool for web designers, developers and professionals to archive web pages for presentation, inspiration and other purposes. At US$4.99, it serves as a very affordable alternative to similar tools such as LittleSnapper.

This Mac App Store version of Clip It! marks an important beginning for the next new App Store only version – Clip It! 2. The development of Clip It! 2 is wrapping up rapidly and it will be available on the App Store as free update to customer who have purchased Clip It! on the App Store.

More will be announced in coming weeks. In the meantime, we hope you enjoy this current version.

Monday, Jan 03, 2011 Clip It will be available in the App Store

Clip It in Mac App Store

Clip It! will be available in the Mac App Store on the launch day. Stay tuned for more detail!

Saturday, Nov 20, 2010 New managed object appear twice in UITableView backed by NSFetchedResultsController

Sample code

I encounter an UITableView row display problem when a managed object context is changed with new managed object inserted and existing ones edited in between save. The UITableView is backed by a NSFetchedResultsController. I suspect it is a bug in Xcode’s template code for project using Core Data.

I tried to search for solution in Google but I don’t seem to find anything detailing this issue.

The problem is…

My app uses UITableView backed by NSFetchedResultsController intensively. The app store data returned by web service. When saving data into the managed object context, we will manipulate the data – modify existing managed object, inserting new managed object.

Using NSFetchedResultsController, I don’t have to worry about writing code to reload data or so. However, if I mix insert and change of managed object in one “save” transaction, the newly inserted managed object will appear twice in the table view.

table view row appear twice

I checked row count returned by numberOfSectionsInTableView:. It is consistent.

Further debugging shows that:

configureCell:atIndexPath: is called twice for row 0. These 2 method calls are invoked by 2 separation change types (NSFetchedResultsChangeType): NSFetchedResultsChangeInsert and NSFetchedResultsChangeUpdate.

Looking at RootViewController.m, this makes sense because, in insertAndChangeObject, new managed object is inserted/added to the managed object context (L109). And, all existing managed objects are modified (L128).

When we save the changes in this “transaction” in one shot (in L135), Core Data should be sending 2 notifications (or sth similar) to the NSFetchedResultsController observing changes in the managed object context it ties to.

NSFetchedResultsController perform these 2 types of changes in one controllerWillChangeContent: controllerDidChangeContent: transaction. That’s where problem happens.

Table row 0 is configured twice. First, table cell at row 0 is directly modified L332. Then, because insertRowsAtIndexPaths: in L321 is called. A new row is inserted to the beginning of the table and configured. Since both row are at index 0 at the instance where “configureCell:atIndexPath:” is called, we have 2 rows showing the same data.

Solution:

Having understand the cause of the problem, we can apply a quick fix. i.e. Separate the managed object insertion and modification. When you are done with all insertions, invoke “save:”. Then, make all managed object changes and save afterwards. We can then get rid of NSFetchedResultsController problem in identifying row index properly in the case where insert and modification happen in the same “transaction”.

Run my sample code. It is almost identical to the iOS Core Data template in Xcode 4.1.

To check my solution, uncomment L119.

Sample code

P.S.: not sure if this problem can be generalized into inserting a new managed object which is adjacent to a modified existing managed object in the table view display order.

Thursday, Sep 23, 2010 Looking for calendar view for iOS?

There’s no built-in calendar view for iPhone which looks like those you found in built-in Calendar app.

Here’s a great post from stackoverflow where you can find some useful URLs.

Tuesday, Sep 07, 2010 iPhone JSON benchmark

iPhone JSON benchmark results posted by Sam Soffes.

Thanks for sharing that!

Older

If you are looking for Finger iPhone app, please go to Finger's site.

Copyright © 2007 Headnix. All rights reserved. Design by BeansBox.