using this tutorial I set up a custom TabBar. Unfortunately the tutorial won't describe how to hide the custom TabBar in views you don't wanna display it.
In my customTabBar.h I defined
- (void) hideAlsoCustomTabBar;
- (void) showCustomTabBarAgain;
which are implemented as
- (void) hideAlsoCustomTabBar {
btn1.hidden = YES;
btn2.hidden = YES;
btn3.hidden = YES;
btn4.hidden = YES;
}
- (void) showCustomTabBarAgain {
btn1.hidden = NO;
btn2.hidden = NO;
btn3.hidden = NO;
btn4.hidden = NO;
}
Calling those inside CustomTabBar.m's viewDidAppear works fine and does exactly what I expect them to do. If I try to call those methods from the ViewController where I need to hide the TabBar like this
[customTabs hideAlsoCustomTabBar];
inside the initWithNibName OR viewDidLoad OR viewWillAppear, nothing will happen. I checked with NSLog, the method gets called, but when I read out the BOOL for any buttons .hidden attribute, it returns 0, when it should be 1 (for hidden==YES).
I don't know what's wrong with my setup. Is it possible these button's attributes are private by default as CustomTabBar inherits from UITabBarController and I can't set them? Or did I make a mistake in the call?
Thanks!
EDIT
The TabBar implementation as it is described in the tutorial
import "CustomTabBar.h"
#implementation CustomTabBar
#synthesize btn1,btn2,btn3,btn4;
- (void) viewDidAppear:(BOOL)animated {
[super viewWillAppear:animated];
[self hideExistingTabBar];
[self addCustomElements];
}
- (void) hideExistingTabBar {
for (UIView *view in self.view.subviews) {
if ([view isKindOfClass:[UITabBar class]]) {
view.hidden = YES;
break;
}
}
}
- (void) addCustomElements {
//Initialise the two images for btnEinleitung, not selected and selected
UIImage *btnImage = [UIImage imageNamed:#"btnEinl.png"];
UIImage *btnImageSelected = [UIImage imageNamed:#"btnEinl_s.png"];
self.btnEinleitung = [UIButton buttonWithType:UIButtonTypeCustom];
btnEinleitung.frame = CGRectMake(0, 430, 86, 50);
[btnEinleitung setBackgroundImage:btnImage forState:UIControlStateNormal];
[btnEinleitung setBackgroundImage:btnImageSelected forState:UIControlStateSelected];
[btnEinleitung setTag:0];
[btnEinleitung setSelected:true];
//set other buttons
btnImage = [UIImage imageNamed:#"btnUbg.png"];
btnImageSelected = [UIImage imageNamed:#"btnUbg_s.png"];
self.btnUebungen = [UIButton buttonWithType:UIButtonTypeCustom];
btnUebungen.frame = CGRectMake(86, 430, 80, 50);
[btnUebungen setBackgroundImage:btnImage forState:UIControlStateNormal];
[btnUebungen setBackgroundImage:btnImageSelected forState:UIControlStateSelected];
[btnUebungen setTag:1];
/* do the same for btn3 and btn4*/
//add custom buttons to view
[self.view addSubview:btn1];
[self.view addSubview:btn2];
[self.view addSubview:btn3];
[self.view addSubview:btn4];
//setup event handlers so the buttonClicked method will respond to the touch up inside event
[btn1 addTarget:self action:#selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[btn2 addTarget:self action:#selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[btn3 addTarget:self action:#selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
[btn4 addTarget:self action:#selector(buttonClicked:) forControlEvents:UIControlEventTouchUpInside];
}
//set tab to active according to the passed tag number
- (void) selectTab:(int)tabID {
switch (tabID) {
case 0:
[btnEinleitung setSelected:TRUE];
[btnUebungen setSelected:FALSE];
[btnTipps setSelected:FALSE];
[btnBrauchtum setSelected:FALSE];
btnEinleitung.userInteractionEnabled = NO;
btnUebungen.userInteractionEnabled = YES;
btnTipps.userInteractionEnabled = YES;
btnBrauchtum.userInteractionEnabled = YES;
break;
case 1:
[btnEinleitung setSelected:FALSE];
[btnUebungen setSelected:TRUE];
[btnTipps setSelected:FALSE];
[btnBrauchtum setSelected:FALSE];
btnEinleitung.userInteractionEnabled = YES;
btnUebungen.userInteractionEnabled = NO;
btnTipps.userInteractionEnabled = YES;
btnBrauchtum.userInteractionEnabled = YES;
break;
// and so on for 2 and 3
}
self.selectedIndex = tabID;
}
//get the tag of the sender/pressed button, call the function selectTab
- (void) buttonClicked:(id)sender {
int tagNum = [sender tag];
[self selectTab:tagNum];
}
EDIT
As described below, I have 4 Tabs in a Tabbar which was generated with IB, added Navigation Controller with their ViewControllers, made Outlets for those and connected them in IB.
Clicking on the second Tab (e.g. sndMenuVC) opens a view with 4 buttons. Clicking one of these buttons leads to another view (e.g. detailVC) in which I don't want the TabBar to be displayed. detailVC has it's own nib.
Opening detailVC happens with the button's action declared like this
- (IBAction) openFourth:(id)sender{
detailVC *detailView = [[detailVC alloc] initWithNibName:#"detailVC" bundle:nil andSender:kFourthButtonSender];
[self.navigationController pushViewController:detailView animated:YES];
[detailView release];
}
As this is a custom initWithNibName, this is how I implemented it
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil andSender: (NSString *)calledByButton{
self.callingButton = calledByButton;
[super initWithNibName:#"detailVC" bundle:nil];
return self;
}
SO I basically just set a global variable "callingButton" according to the transmitted sender and call the "normal" initWithNibName afterwards.
This all works fine.
If I try to call hideAlsoCustomTabBar, and NSLog the value of btn1.hidden it returns 0 when called from detailVC, but returns 1 when called from within CustomTabBar and actually hides the buttons.
I have customTabs as IBOutlet if needed, but don't know if this is connected correctly to the TabBarController of type CustomTabBar.
Hope this helps to understand me :) If you need any other information, just let me know.
Thanks!
I have written a follow up to my RXCustomTabBar tutorial which should answer your questions. I don't see any point reproducing it in full here.
Hiding your New Custom UITabBar (RXCustomTabBar follow up)
Let me know if you have any questions,
Oli
if you want to hide the tabBar you can simply, in your view controller, call
[[[self tabBarController] tabBar] setHidden:YES];
In RXCustomTabBar.m file addCustomElements function is called from viewDidAppear.
-(void)addCustomElements
{
.
.
.
.
// Add my new buttons to the view
// Following lines are adding buttons to the view. Put your condition here according to requirement so that it will check and add buttons accordingly.
[self.view addSubview:btn1];
[self.view addSubview:btn2];
[self.view addSubview:btn3];
[self.view addSubview:btn4];
.
.
.
.
}
Hope this helps.
Update
//Add following function in RXCustomTabBar.m
-(void)hideButtons
{
btn1.hidden = YES;
btn2.hidden = YES;
btn3.hidden = YES;
btn4.hidden = YES;
}
- (void)selectTab:(int)tabID
{
switch(tabID)
{
case 0:
[btn1 setSelected:true];
[btn2 setSelected:false];
[btn3 setSelected:false];
[btn4 setSelected:false];
break;
case 1:
[self hideButtons]; //Call function for hiding buttons like this.
[btn1 setSelected:false];
[btn2 setSelected:true];
[btn3 setSelected:false];
[btn4 setSelected:false];
break;
}
self.selectedIndex = tabID;
}
Let say you want to hide buttons on 2nd View Controller. So I have called [self hideButtons] in case 1 index.
This will Hide all the tabbar buttons. And again Viceversa you have to put diff condition to show those tab buttons.
Does this make sense ?
Since the custom tabs exists already at the point this method is called. You should assign it to detailView's customTabs property here.
- (IBAction) openFourth:(id)sender{
detailVC * detailView = [[detailVC alloc] initWithNibName:#"detailVC" bundle:nil andSender:kFourthButtonSender];
detailView.customTabs = **theExistingCustomTabsObject**;
[self.navigationController pushViewController:detailView animated:YES];
[detailView release];
}
Orignal Answer
As the reference to the subclass of the UITabBarController is nil, you will have to set it properly. If you have used IB to set the view controllers, go to the NIB file. Right click on the view controller, select the customTabs outlet and connect it to the customTabBar object holding the view controllers.
If you've created the view controllers programmatically then somewhere after adding the view controllers to the tab bar and before releasing the view controllers, do this,
viewController.customTabs = self.customTabBarObject;
Related
How do I call this method from the button selector code I have below:
- (void)displayEditorForImage:(UIImage *)imageToEdit
{
AFPhotoEditorController *editorController = [[AFPhotoEditorController alloc] initWithImage:imageToEdit];
[editorController setDelegate:self];
[self presentViewController:editorController animated:YES completion:nil];
}
here's the UIButton I'm trying to call the method with:
//edit button
UIButton *editButton = [UIButton buttonWithType:UIButtonTypeRoundedRect];
[editButton addTarget:self
action:#selector(editBtnTouch)
forControlEvents:UIControlEventTouchDown];
[editButton setTitle:#"Effects" forState:UIControlStateNormal];
**// the following line shows the selector where I'm unsure how to call the method from the code above**
if ([[UIScreen mainScreen] respondsToSelector:#selector(displayEditorForImage:)] &&
([UIScreen mainScreen].scale == 2.0)) {
// Retina display
editButton.frame = CGRectMake(220.0, 320.0, 60.0, 40.0);
} else {
editButton.frame = CGRectMake(220.0, 315.0, 60.0, 40.0);
}
[self.view addSubview:editButton];
thanks for the help
When the selector you add to the button is called, the button itself will be passed as the first argument if the selector allows for one. In order to get a reference to your image, you would either need to do this (assuming the image you want is the background image for the button):
- (void)displayEditorForImage:(UIButton*)sender {
UIImage* imageToEdit = [sender backgroundImageForState:UIControlStateNormal];
AFPhotoEditorController *editorController = [[AFPhotoEditorController alloc] initWithImage:imageToEdit];
[editorController setDelegate:self];
[self presentViewController:editorController animated:YES completion:nil];
}
Or you would need to make a custom UIButton that has an extra property for the associated image, and then just access the image through the button in the selector:
- (void)displayEditorForImage:(UIButton*)sender {
if([sender isKindOfClass:[YourCustomButtonClass class]]) {
UIImage* imageToEdit = ((YourCustomButtonClass*)sender).customImageProperty;
AFPhotoEditorController *editorController = [[AFPhotoEditorController alloc] initWithImage:imageToEdit];
[editorController setDelegate:self];
[self presentViewController:editorController animated:YES completion:nil];
}
}
Edit:
You seem to be confused as to how to make a UIButton call a method on when it is tapped. You need to add the object which defines the method as the button's target (in this case self), add the method as the selector, and to called the method when the button is tapped use the UIControlEventTouchUpInside. So your code would be:
[editButton addTarget:self action:#selector(displayEditorForImage:) forControlEvents:UIControlEventTouchUpInside];
HiI am very new to iphone development.I am java background developer.So my approach is like java .
Here my requirement is that i want to call one global function from every view controller.
and from there i pass self.navigationController as a parameter. In that function i add some buton. when user click on that button it should call one more function and it should carry same object as a parameter.
please give me guidance. i tried as following but it is showing error at compiletime
Utilities.m
+(void)setBacKButton:(UINavigationController *)navigationController
{
for(UIButton *btn in navigationController.navigationBar.subviews){
if([btn isKindOfClass:[UIButton class]]){
[btn removeFromSuperview];
}
}
UIButton *btn2=[UIButton buttonWithType:UIButtonTypeCustom];
btn2.frame=CGRectMake(708, 0, 50, 54);
[btn2 setImage:[UIImage imageNamed:#"btn_back.png"] forState:0];
[btn2 setImage:[UIImage imageNamed:#"btn_back_h.png"] forState:UIControlStateSelected];
// here i need to call bellow function when click on this button
//[btn2 addTarget:self action:#selector() forControlEvents:UIControlEventTouchUpInside];
[navigationController.navigationBar addSubview:btn2];
}
+(void)gotoBack:(UINavigationController *)navigationController
{
[navigationController popViewControllerAnimated:YES];
}
and i call that function from my viewcontroller as
[Utilities setBacKButton:self.navigationController];
please tell me how we can achieve this
add a function in your app delegate.and call that function in all your view controllers.with an object of appdelegate.then with in that function add one button with id sender and do watever u want in the method.
Just make a navigation controller in your app Delegate ... and push your view controller using this.. follow the following code...
//YourAppdelegate.h
UINavigationController *navController;
#property(nonatomic,retain)UINavigationController *navController;
// your appdelegate.m
navController = [UINavigationController alloc]initWithRootViewController:self.viewController];
self.window.rootViewController = navController ;
and now make your global function here (in appdelegate.m) like.......
- (void)setBacKButton:(UINavigationController *)navigationController{
// put your code here
}
now call it from your view controllers where you have needed like this...
// yourViewController.m
import "yourAppdelegate.h"
and when you have to call that function just write these two lines..
YourAppdelegate *appdelegate = (YourAppdelegate*)[[UIApplication sharedApplication]delegate];
[appdelegate setBacKButton:self.navigationController];
may this will help you
you would want to create a category of UINavigationBar.
UINavigationBar+customBackButton.h
#import <UIKit/UIKit.h>
#interface UINavigationBar (customBackButton)
- (void)setCustomBackButton;
#end
UINavigationBar+customBackButton.m
#import "UINavigationBar+customBackButton.h"
#implementation UINavigationBar (customBackButton)
- (void)setCustomBackButton
{
for(UIButton *btn in self.subviews)
{
if([btn isKindOfClass:[UIButton class]])
{
[btn removeFromSuperview];
}
}
UIButton *btn2=[UIButton buttonWithType:UIButtonTypeCustom];
btn2.frame=CGRectMake(708, 0, 50, 54);
[btn2 setImage:[UIImage imageNamed:#"btn_back.png"] forState:0];
[btn2 setImage:[UIImage imageNamed:#"btn_back_h.png"] forState:UIControlStateSelected];
// here i need to call bellow function when click on this button
//[btn2 addTarget:self action:#selector() forControlEvents:UIControlEventTouchUpInside];
[self addSubview:btn2];
}
#end
Then in any view controller you can import it like this
#import "UINavigationBar+customBackButton.h"
[self.navigationController.navigationBar setCustomBackButton];
Following the response from #ewiinnnnn above, I came up with a way to use Custom Categories and have the back button navigate as expected:
// UIViewController+customBackButton.h
#import <UIKit/UIKit.h>
#interface UIViewController (customBackButton)
- (void)setCustomBackButton;
#end
// UIViewController+customBackButton.m
#import "UIViewController+customBackButton.h"
#implementation UIViewController (customBackButton)
// sets my custom back button
- (void)setCustomBackButton
{
UINavigationItem *navItem = self.navigationItem;
UIButton *customButton = [UIButton buttonWithType:UIButtonTypeCustom];
UIImage *addButton = [UIImage imageNamed:#"backButton.png"];
UIImage *addButtonSelected = [UIImage imageNamed:#"backButtonHighlighted.png"];
[customButton setBackgroundImage:addButton forState:UIControlStateNormal];
[customButton setBackgroundImage:addButtonSelected forState:UIControlStateHighlighted];
customButton.frame=CGRectMake(0.0, 0.0, addButton.size.width, addButton.size.height);
[customButton addTarget:self action:#selector(navigateBack) forControlEvents:UIControlEventTouchUpInside];
UIBarButtonItem *barButtonItem = [[UIBarButtonItem alloc] initWithCustomView: customButton];
navItem.leftBarButtonItem = barButtonItem;
}
// the action that is triggered when the back button is pressed
- (void)navigateBack {
[self.navigationController popViewControllerAnimated:YES];
}
#end
And then within a UIViewController:
// MyViewController.m
#import "UIViewController+customBackButton.h"
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
// add back button to navcontroller
[self setCustomBackButton];
}
I have a custom header view in my iphone app. and it have a custom button over that.
But that custom button action is not fire but header tap event is fired which is in custom class .Please help me .How to fire action on button in header view.
- (UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section
{
NSNumber *num=[NSNumber numberWithInt:section];
UIView * customView = [[[UIView alloc] initWithFrame:CGRectMake(0,0,320,50)]autorelease];
customView.tag = section;
[customView setUserInteractionEnabled:YES];
customView.backgroundColor = [UIColor blackColor];
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(260, 7, 25, 25);
button.tag=section;
[button addTarget:self action:#selector(expandCollapsing:) forControlEvents:UIControlEventTouchUpInside];
[button setImage:[UIImage imageNamed:#"add.png"] forState:UIControlEventTouchUpInside];
[button setSelected:YES];
}
You can implement your own callback method to do this.
What i did is I added a TapGesture to the customView. When the event is fired i used a callback method to pass the control to the viewController where my tableView is implemeted
What you can do While loading the header you can assign the tag value to the customView
customHeader.tag = 1;
and you can implement the call back method in your viewController.
In CustomheaderView
UITapGestureRecognizer *recognizer = [[UITapGestureRecognizer alloc] initWithTarget:self action:#selector(checkBoxEventHandler:)];
[recognizer setNumberOfTapsRequired:1];
[recognizer setNumberOfTouchesRequired:1];
[self setGestureRecognizers:[NSArray arrayWithObject:recognizer]];
-(IBAction)checkBoxEventHandler:(id)sender
{
if ([self.delegate respondsToSelector:#selector(selectedHeader: atIndex:)])
{
[self.delegate selectedHeader:self atIndex:self.tag];
}
}
In your viewController.m
-(void)selectedHeader:(myCustomHeader *)header atIndex:(int)index
{
//header -> will give you the same instance you created in your viewController while loading this custom header view
// So you can check the tag like this
if(header.tag == 1)
{
//Do Stuff here
}
// index -> we are passing headerViews tag as index ie header.tag is equal to index
// So checking the tag like this is the proper way
if(index == 1)
{
//Do Stuff here
}
}
Just paste this code will solve your problem :
-(UIView *)tableView:(UITableView *)tableView viewForHeaderInSection:(NSInteger)section{
UIButton *button=[UIButton buttonWithType:UIButtonTypeCustom];
button.frame=CGRectMake(50.0, 0.0, 25, 25);
[button setImage:[UIImage imageNamed:#"add.png"] forState:UIControlStateNormal];
button.tag=section;
[button addTarget:self action:#selector(expandCollapsing:) forControlEvents:UIControlEventTouchUpInside];
[button setSelected:YES];
return button;
}
-(void)expandCollapsing:(id)sender {
UIButton *btn=(UIButton*)sender;
NSLog(#"Tag:%d",[btn tag]);
}
In my application i need an edit button for my tableview that can delete a row or can change its position.
it is really easy when i am using a default navigation bar but now in my case i am using a custom bar that is infect an imageview & now i need a button that can edit a tableview. i am not using the default navigation bar.
so plz help me
You just need to set the editing property of the UITableView, in your UITableViewController implement something like;
- (void) editingButtonPressed:(id)sender {
if([self isEditing]) {
[sender setText:#"Edit" forState:UIControlStateNormal];
[self setEditing:NO animated:YES];
} else {
[sender setText:#"Done" forState:UIControlStateNormal];
[self setEditing:YES animated:YES];
}
}
And hook that up to your button or image and replace the setText with setImage if you have no text.
Here is my init method for a UITableViewController using a custom UIToolbar which adds two buttons to the navigation bar in place of the right navigation bar button.
- (id) init {
[super initWithStyle:UITableViewStyleGrouped];
UIBarButtonItem *email = [[[UIBarButtonItem alloc] initWithImage:[UIImage imageNamed:#"Email.png"] style:UIBarButtonItemStyleBordered target:self action:#selector(composeEmail:)] autorelease];
UIBarButtonItem *bookmark = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemAdd target:self action:#selector(addBookmark:)] autorelease];
[bookmark setStyle:UIBarButtonItemStyleBordered];
CustomToolbar *buttonToolbar = [[CustomToolbar alloc] initWithFrame:CGRectMake(0, 0, 93, 45)];
[buttonToolbar setBarStyle:UIBarStyleBlackTranslucent];
[buttonToolbar setItems:[NSArray arrayWithObjects:email, bookmark, nil] animated:NO];
[[self navigationItem] setTitle:#"Table with Custom Toolbar"];
[[self navigationItem] setRightBarButtonItem:[[[UIBarButtonItem alloc] initWithCustomView:buttonToolbar] autorelease]];
[buttonToolbar release];
return self;
}
When creating the buttons I use action:#selector(customMethodName) when creating the buttons to hook up my methods to the button actions in this case composeEmail and addBookmark which load the new views for those tasks.
you can add a button on your imageview and on that button click set your tableviewediting to yes.
here's the code how to add a imageview and button:-
UIImageView *imageView2=[[UIImageView alloc]initWithFrame:CGRectMake(0, 0, 320, 50)];
[imageView2 setImage:[UIImage imageNamed:#"bottom bar_gda.png"]];
[self.view addSubview:imageView2];
[self.view bringSubviewToFront:imageView2];
UIButton *deleteButton = [UIButton buttonWithType:UIButtonTypeCustom];
[deleteButton setFrame:CGRectMake(280, 3, 26, 36)];
deleteButton.contentMode = UIViewContentModeScaleAspectFill;
UIImage *newImage12 = [UIImage imageNamed:#"check.png"];
[deleteButton setBackgroundImage:newImage12 forState:UIControlStateNormal];
[deleteButton setBackgroundImage:newImage12 forState:UIControlStateHighlighted];
[deleteButton addTarget:self action:#selector(editmethod:) forControlEvents:UIControlEventTouchUpInside];
[imageView2 addSubview:deleteButton];
You have to add UIButton instance to that imageview and implement a method that will execute when an event occurs on that UIButton.
Code for the method will look like,
if(tableView.editing)
[tableView setEditing:NO animated:YES]
else
[tableView setEditing:YES animated:YES]
Read UITableView Documentation for more info.
YOU CAN USE SWIPE TO DELETE FEATURE.
THIS CAN BE DOEN IN FOLLOWING WAY.
you need to implement following 3 delegate method of tableView.
tableView:commitEditingStyle:forRowAtIndexPath:
tableView:canEditRowAtIndexPath:
tableView:editingStyleForRowAtIndexPath:
In method
tableView:editingStyleForRowAtIndexPath:
RETURN TYPE SHOULD BE
UITableViewCellEditingStyleDelete.
I've set up a Button and add it to a view. I want to add a "done" button to the UIKeyboardTypeNumberPad. Here's my code.
UIButton *doneButton = [UIButton buttonWithType:UIButtonTypeCustom];
doneButton.frame = CGRectMake(0, 163, 106, 53);
doneButton.adjustsImageWhenHighlighted = NO;
[doneButton setImage:[UIImage imageNamed:#"DoneUp.png"] forState:UIControlStateNormal];
[doneButton setImage:[UIImage imageNamed:#"DoneDown.png"] forState:UIControlStateHighlighted];
[doneButton addTarget:self action:#selector(doneButton:) forControlEvents:UIControlEventTouchUpInside];
// locate keyboard view
UIWindow* tempWindow = [[[UIApplication sharedApplication] windows] objectAtIndex:1];
UIView* keyboard;
for(int i=0; i<[tempWindow.subviews count]; i++) {
keyboard = [tempWindow.subviews objectAtIndex:i];
// keyboard view found; add the custom button to it
if([[keyboard description] hasPrefix:#"<UIKeyboard"] == YES)
[keyboard addSubview:doneButton];
}
Everything works great until I want to remove the button if I've got a Kayboard of type NumbersAndPunctuation for example.
If I click the button I use [(UIButton)*sender removeFromSuperview];
to prevent memory leaks.
But how do I remove the button from within an other function?
Thanks a lot!
Some other guys did ask that question somewhere else but didn't get a answer. I'am sure you can help :)
// Where self is a UIView subclass
NSLog(#"subviews: %#",self.subviews);
for(id view in self.subviews ){
if ([view isKindOfClass:[UIButton class]]) {
NSLog(#"Removing a button!");
[view removeFromSuperview];
}
}
You should store a reference to the button, instead of using a local variable. For example:
Header file:
#interface myObject : NSObject {
UIButton *doneButton;
...
Implementation file:
doneButton = [UIButton buttonWithType: UIButtonTypeCustom
...
To remove it (assuming you're in the same object:
[doneButton removeFromSuperview];
However, Apple may not take kindly to you adding buttons to their keyboard.
you can declare your button in your .h file, so you will be able to get access from all class methods