how to add custom keyboard - objective-c

I did a simple application.
My application contains 10 Text fields.
what i need is i need to hide default keypad i place manual keys like this
How can i done this keys works as a keypad to my app.
can any one pls post some code or link.
Thank u in advance.

I wrote a KeyPad, that is easy to customize via its delegate.

Just add a view with 10 buttons and assign action for each of them.
In the didBeginEditing method diss the keyboard using,
[textField resignFirstResponder]
[yourKeyboard show];
And i think apple will reject the applications using custom keyboard

There is a complete thread about that here
It has a tutorial, lots of comments, sample code and project, everything you need is there. (Is quite long though)
You basically create a view with your buttons for example and
In iOS3.2 and above you can use inputView property of your textField.
In early iOS versions you have to do a trick (add your keyboard as a subview of UIKeyboard) that is also written in the link.
If you need more advanced stuff than simple numbers, you probably want to look at UIKeyInput and UITextInput protocols.
Hope it helps

Related

iOS text popup with clickable links

I'm looking for a simple solution to presenting popup text in an iOS app that contains text with hyperlinks.
At the moment, my text pops up as a UIAlertView. The user has a 'Close' button below which dismisses the box. However, this class (UIAlertView) doesn't allow the use of hyperlinks within the message text. I understand that creating a whole new custom UIAlertView is frowned upon (not to mention probably overkill for what I want to achieve).
Perhaps I'm barking up the wrong tree by using UIAlertViews. I'm new to iOS and don't know the scope of what's available. Essentially, I need a dialog (or window) to pop up, containing a string of text, a (close/back/dismiss) button, and possible hyperlinks within the text. Those hyperlinks in turn launch other popups/windows/dialogs of their own.
What I'm working on here is a simple dictionary application. It's a table view containing terms. The terms lead to definitions, and in most cases, the definitions themselves reference other terms. Fairly simple, and if possible I'd like to use standard API classes.
Any wisdom would be appreciated. If I truly have to go down the route of creating my own custom UIAlertView class, then sobeit! In this case, some pointers for lightweight class creation would be appreciated. I'm not looking to add fancy colours or anything, just the ability to click on bits of text.
I think you'll need to create your own UIView sub-class to do the trick, controlled by a UIViewController subclass. One trick I've used to make it look more like an alert view is to have your main popup view embedded in a fullscreen view with a clear background.
In general, Apple SDKs make it really easy to do standard things (UIAlertView), but if you want to tinker with it (embedded links), you need to do it yourself.

possibility of setting the Voice Over Cursor in Objective-C

I am programming a text-based RPG for Voice-Over users on the iPhone.
I've got multiple UIViews added to my viewcontroller for different events.
I often remove and add them to my main View.
My Question is as follows: is it possible to update the VoiceOver Cursor to focus on the first Element on the View so the User doesn't has to check every Time if there has happened something new?
I figured out that this happens in a Navigationcontroller.
Is there a functionality to do this?
By posting a UIAccessibilityLayoutChangedNotification, you inform VoiceOver that the layout of the screen has changed. You can also use UIAccessibilityAnnouncementNotification if you want to make a specific announcement.
UIAccessibilityPostNotification(UIAccessibilityLayoutChangedNotification, nil);
Reference: UIAccessibility Protocol Introduction, Notifications
You can't control the VoiceOver cursor in iOS 4 or 5. I wish you could, it would solve so many issues.
I think this will be possible with iOS 6. See this answer for more info on that: https://stackoverflow.com/a/11995385/1455770

How to create a custom NSMenuItem

Well, I have quite a basic question which I can't seem to find an answer to. I followed this guide to create a StatusBar menu, which works great...
However, I would like to add a custom NSMenuItem containing custom stuff. As example such as the sound slider, or the switch user account row ect.
How can I do that?
Even links to tutorials are welcome.
In most cases, you'll create a custom view containing the slider or whatever else you want to appear in the menu item. Then you call setView: on the NSMenuItem in question.
For more details, check this article from Apple's documentation:
https://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/MenuList/Articles/ViewsInMenuItems.html
Just use the setView: method of NSMenuItem.

Is assigning the same Action-method to multiple Cocoa UI objects e.g. NSButton possible?

I'm currently learning ObjC and Cocoa programming, coming from the Java world.
To test my current skills and learning progress I'm creating a small calculator app from scratch (OSX not iOS).
My UI has 10 digit buttons 0-9 among others.
My first thought was, since the action receives the senders reference, to make one action
like -(IBAction)captureDigit:(id)sender and then just grab the digit from the button title.
But the interface builder only allows an action to be connected with one sender it seems.
So I ended up creating 10 captureDigit actions in my controller.
My Question:
is the first option possible somehow? I thought of adding the actions programmatically (is this possible?) to the buttons, but then I would have to add all digit buttons as outlets to my controller.
Bonus Question:
can a NSButton hold some kind of non visible value? Could not find this in the documentation.
Maybe this would violate the MVC pattern as the UI would then know of application specific data?
Thanks for any useful and kind answer in advance, I'm still learning
You can connect many senders to one target/action if you Control-drag from senders to the target, so that's not a problem.
WRT your bonus question, any NSView has an integer tag which you can set in Interface Builder. That's a convenient way to differentiate multiple similar views.
You can definitely connect more than more button to a single action. Also, you can use the tag field of any object to give it a "behind the scenes" value.
It's perfectly possible to add as many actions to a single controller. How is Interface Builder preventing you from doing this?
You could have a NSDictionary instance in your controller, in which you could match NSButtons to whatever data you want.
To make it easy, in IB create one button and drag from NSButton to File's owner it then shows all of the methods that we can send to NSButton, then select captureDigit:. Now copy and paste the button change the title, copy and paste in IB keeps the connection and use tag field as costique, nitrex have already said.

Placing a text field in a Menulet in Mac OS X

I'm working on an menulet-based application for the Mac that requires me to have a text field in the menu. I've searched high and low and have not found any examples of how to do this, yet I have seen many menulet apps that implement a text field. I've found no way to do it from Interface Builder, so I guess this text field would need to be defined and added to the menu programmatically.
If anyone could help me with this issue, it would be greatly appreciated.
An NSTextField is a view based subclass, therefore in code, when you create the NSMenuItem you must use the – setView: property and add the NSTextField to the menu item.
Also if you use an NSStatusItem, it also has a -setView: property.