开发者

IPHONE - How to initialize a button using editButtonItem

开发者 https://www.devze.com 2023-01-31 13:27 出处:网络
I want to use table edit function. I know self.navigationItem.rightBarButtonItem = self.editButtonIt开发者_运维技巧em;

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;

}

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号