Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

dpatel

macrumors newbie
Original poster
May 25, 2013
8
0
I am using xcode 4.6.2, and i am having trouble making a custom toolbar on top of the ipad keyboard which has a previous, next and done button. I have looked at many videos and forums but i cannot relate to any. I am a beginner by the way and i have tried out things by myself, and the furthest i have gotten is the creation of two text boxes :D

something similar to this http://i.stack.imgur.com/8gOEW.png
Help would be much appreciated!
Thanks.
 
Last edited:
What have you tried? What code have you written? There's a property called something like accessoryKeyboardView or something that you should assign on the view which uses the keyboard.

Also, this is the wrong section of the forums. You posted in the Mac Programming section but this is an iOS Programming question.
 
ive got this in the .h file at the moment.

Code:
IBOutlet UITextField *textField1;
IBOutlet UITextField *textField2;

    UIToolbar *keyboardToolbar;
}

@property (nonatomic, retain) IBOutlet UITextField *textField1;
@property (nonatomic, retain) IBOutlet UITextField *textField2;
@property (nonatomic, retain) UIToolbar *keyboardToolbar;

- (void)resignKeyboard: (id)sender;
- (void)previousField: (id)sender;
- (void)nextField: (id)sender;

this is what i put in my .m file so far

Code:
- (void)dealloc {
    
    [textField1 release];
    [textField2 release];
    [keyboardToolbar release];
}

i havent done much obviously but thats because all the tutorials i have seen are for iphone only, and i want this feature to be for ipad. I am very new to this so youll have to bear with me and help me with my silly questions lol.
 
What tutorials are you using? Provide links if they're online or the publisher, the author, the title, and the edition if you got this from a print source.

(Can we have a help bot that automatically provides these responses or something? Maybe pop up error messages when someone posts something asking for help and is vague - IE, it notices the word "tutorial" or "guide" and a lack of publishing information or a link.)

Anyways, this probably works exactly the same on an iPad and an iPhone. What makes you think otherwise?
 
one of them was a youtube video, here is a link for that:
http://www.youtube.com/watch?v=YgeuauhsDhQ

and the other was a blog:
http://gabriel-tips.blogspot.co.uk/2011/05/input-accessory-view-how-to-add-extra.html

they are both for adding UItoolbars over the UIkeyboards, and they are both in .xib files. the .xib file may be the same as a .storyboard file, but i cant seem to find the files owner section where you link the textfield1 with the actual text box on the design view.
Also i thought coding may be different with iPad and it wouldnt recognize some of the commands.
 
just need to find out how to link up my textField1 variables with my text box objects now..
 
anyone able to help? im either doing something wrong or its right in front of my eyes, but i cant link the textbox to the textField1 variable i created. And this error is what comes up when i release the objects:
Code:
    [textField1 release];         ARC forbids explicit message send of 'release'
    [textField2 release];           'release' is unavailable: not available in automatic reference counting mode
    [keyboardToolbar release];  ARC forbids explicit message send of 'release'
    [super dealloc];                ARC forbids explicit message send of 'dealloc'

I found these examples from the youtube video i linked above, and when he did the same thing, no errors showed.
 
Last edited:
You have ARC enabled, remove your dealloc method.

I suggest reading beginner tutorials/books
 
ok i have disabled ARC, but its not letting me conect my UItextfield with my variables:

Code:
    IBOutlet UITextField *textField1;
    IBOutlet UITextField *textField2;

Code:
    @property (nonatomic, retain) IBOutlet UITextField *textField1;
    @property (nonatomic, retain) IBOutlet UITextField *textField2;

i can see the little spots where i can connect the variables to the text-boxes, but they aren't highlighting to show actions......:confused:
 
ok i have disabled ARC, but its not letting me conect my UItextfield with my variables:

Code:
    IBOutlet UITextField *textField1;
    IBOutlet UITextField *textField2;

Code:
    @property (nonatomic, retain) IBOutlet UITextField *textField1;
    @property (nonatomic, retain) IBOutlet UITextField *textField2;

i can see the little spots where i can connect the variables to the text-boxes, but they aren't highlighting to show actions......:confused:

Take a timed screenshot to show us what you mean (using Applications/Utilities/Grab.app if you don't know the shortcut.) I don't understand what you're saying isn't working...
 
ok the two screenshots are attached below. Basically the problem for me is that the blue line should connect with the text box and show me a range of segues i can use. Its not showing anything and its not even linking up. The screenshots will show you what i mean
 

Attachments

  • variableconnection.png
    variableconnection.png
    686.9 KB · Views: 214
  • propertyconnection.png
    propertyconnection.png
    680.6 KB · Views: 176
ok the two screenshots are attached below. Basically the problem for me is that the blue line should connect with the text box and show me a range of segues i can use. Its not showing anything and its not even linking up. The screenshots will show you what i mean

You are confusing connecting outlets to connecting scenes with a segue.

The screen-shots you posted show you connecting an IBOutlet to a field. That's an important step, but is completely different from linking segues. To connect a segue, you need to have multiple scenes in your storyboard.
 
ok the two screenshots are attached below. Basically the problem for me is that the blue line should connect with the text box and show me a range of segues i can use. Its not showing anything and its not even linking up. The screenshots will show you what i mean

To follow up:

The blog post you linked spells out in detail how to create and set up a keboard accessory view. To summarize:

You need to connect an outlet to your text view, as you show in your screen shots.

You need to connect the delegate property of your text field to your view controller the same way (drag from the delegate property onto "file's owner". Connecting this way tells the text field that your view controller is it's delegate. At key times in the user's interaction with the text view, the text field will try to call methods in your view controller to tell it about what's happening, and/or ask the delegate what it should do next.

To add an accessory view to your keyboard, you need to implement the method textFieldDidBeginEditing, and in that method, call code that installs the accessory view you created as the text field's accessory view (using the UITextField method setInputAccessoryView.

If you read the description of the UITextField's inputAccessoryView property, it says:

inputAccessoryView
The custom accessory view to display when the text field becomes the first responder

@property (readwrite, retain) UIView *inputAccessoryView
Discussion
The default value of this property is nil. Assigning a view to this property causes that view to be displayed above the standard system keyboard (or above the custom input view if one is provided) when the text field becomes the first responder. For example, you could use this property to attach a custom toolbar to the keyboard.

The code you posted is just a header file and a dealloc method. You did not post any code that would create or install an accessory view. Did you not understand the instructions in the blog post? They spell out what you need to do in detail.
 
ok thanks for the help, ive connected the text fields to the view controller and it worked, just need to add some more code now, as the custom buttons ive created arent appearing. Cheers!
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.