IPHONE - How to initialize a button using editButtonItem
I want to use table edit function. I know self.navigationItem.rightBarButtonItem = self.editButtonIt开发者_运维技巧em; However I want to set a UIButton set it as editButtonItem or can do edit table function
You cant use self.editButtonItem because it is present when your class is subclass of UITableView.
But you can achieve same functionality by the following code-
use a bool variable (declare in .h file says isEdit).
-(IBAction)editTable
{
if(!isEdit)
{
isEdit=YES;
yourTableView.editing=YES;
}
else
{
isEdit=NO;
yourTableView.editing=NO;
}
}
bind this IBAction to the button. you can also change the text of the button and style also by setting property of the button.
just write your code in onclick of UIButton ,that s
-(IBAction)deletebuttonPresed:(id)sender {
table.editing=YES;
}
精彩评论