Archive

Archive for August, 2010

Close this Number Keypad I shall not see!

  • Did you ever use an iPhone app with a Number Keypad to edit numbers only fields?
  • Did you ever wonder how you could close the keypad, just like you would do with the standard keyboard and its ‘Done’ button?
  • Are you sure you want to know the answer…?

YOU CAN’T! (at least if the application just used the standard Number Keypad provided within iOS SDK)

So, what choice do you have?

  • Generally, the keypad closure is not really necessary, since the edited field is in its own screen, you just let the user go back (generally through the navigation bar) and the keypad is closed automatically.
  • You may imagine other solutions, too…
  • But the one I’ll give you here offers the following result:
Simulateur iPhone
Uploaded with plasq‘s Skitch!

Now that you’ve seen this, you wan’t to know how to do it, don’t you? So here’s the howto! It’s not my own creation, I followed their tutorial and used the graphic files provided, so you can do so! I just poured a little bit of idea I found on another blog to make it a little more better (to me at least).

So this idea is just to use the powerfulness of Cocoa’s categories (extending classes without subclassing), to add a method to the UIView class enabling me to find the firstResponder from a view and resign it. Calling this method on the app’s main window when I want to close the keypad, it will seek and find the firstResponder, resign it, and thus close the keypad! Easier, isn’t it? And the corresponding is below…

#import 

@interface UIView ( RoCHExtensions )
- (UIView *)findAndResignFirstResponder;
@end

@implementation UIView (RoCHExtensions)
- (UIView *)findAndResignFirstResponder {
    if (self.isFirstResponder) {
        [self resignFirstResponder];
		return self;
    }

    for (UIView *subView in self.subviews) {
        UIView *firstResponder = [subView findAndResignFirstResponder];

        if (firstResponder != nil) {
			[firstResponder resignFirstResponder];
			return firstResponder;
        }
    }

    return nil;
}
@end
Advertisements

Now more community sharing!

I just activate old and new functions with WordPress:

  • Rating on posts and comments, so do not hesitate to tell what you like, and what you don’t!
  • Sharing links to share posts with your friends on Twitter, Facebook and many more!

Enjoy the community!

Categories: Blog life Tags: ,

Make Wireshark work on OS X

You just have to make the BPF file of libcap readable with the following command (in your terminal):
sudo chown {your account name} /dev/bpf*

Original tip source

Categories: Mac OS X Tips Tags: , , ,
%d bloggers like this: