开发者

how to hide or remove UIbutton from headerview

I have a button in headerview of my tableview, its woking fine as well, but problem i am having is: When I want to hide that button on click of another button. How can I achieve this? I have already tried [deletebutton removeFromSuperview];

where deleteButton is my buttons name.

Here is what I am doing

-(void)PutTableinEditMode{

DeleteButton=[UIButton buttonWithType:UIButtonTypeCustom];

DeleteButton.frame=CGRectMake(10,1, 65, 25);

[DeleteButton setTitle:@"Delete" forState:UIControlStateNormal];

DeleteButton.backgroundColor=[UIColor clearColor];

[DeleteButton addTarget:self action:@selector(DeleteMultipleToDos) forControlEvents:UIControlEventTouchUpInside];

[headerView addSubview:开发者_开发百科DeleteButton];

}

Then I m having another function as below from where i want to hide this DeleteButton

-(void)DoneEditing {

DeleteButton.hidden=YES;

[DeleteButton removeFromSuperview];

}


deletebutton.hidden = YES


if any of those two solution (removeFromSuperview and hidden) do not work, then you certainly don't have the right reference to your button. I guess your using nib files to define your views ? Then be sure the member deleteButton is well "linked" to the actual button. (i.e. verify using debug that your deleteButton var is not null)


Can u try and change the Text of that button because i'm thinking your sending messages to nil objects.


I got the it working actually [DeleteButton removeFromSuperView] is working .. problem was that the first method PutTableinEditMode was being called from somewhere else also, so i simply took a bool variable and on basis of its value added and removed the delete button :)

Thanks guys for helping though :) Ifeel so stupid to make such a silly mistake :)

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜