0
我有這個按鈕,在這裏我設置在節目的開始,現在,如果我試圖隱藏或顯示它之後我把他它的工作原理:無法隱藏按鈕?
button.hidden=YES; //set yes or no does works ,
如果我嘗試這樣做,後來,當我點擊它時,它不會消失。
-(void)outb:(UIButton*)button
{
NSLog(@"%@",button); //has a pointer
button.hidden=YES;
butotnPointer.hidden=YES;
不起作用。
這裏的按鈕:
//OUT
self.outb = [UIButton buttonWithType:UIButtonTypeCustom];
self.outb.contentHorizontalAlignment=UIControlContentHorizontalAlignmentCenter;
self.outb.backgroundColor=[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.4];
[self.outb addTarget:self action:@selector(outb:)forControlEvents:UIControlEventTouchUpInside];
UIImage *outImage = [UIImage imageNamed:@"outButton.png"];
[self.outb setImage:outImage forState:UIControlStateNormal];
self.outb.frame=CGRectMake(heart.frame.origin.x-bw, startY+(heart.frame.size.width-bh)/2.0, bw, bh);
self.outb.backgroundColor=[UIColor clearColor];
[self.view addSubview:self.outb];
檢查你的指針。 Check is self.outb指針與你在IBAction上得到的指針相同,outb:(UIButton *)按鈕。您可能實際上放置了2個按鈕(您的init代碼執行了兩次),然後您隱藏了最上面的按鈕,但仍然可以看到它下面的那個按鈕 – Lefteris 2014-11-05 15:15:38
檢查您的init代碼,它放置的是哪種方法? – mityaika07 2014-11-05 15:18:48
if(button.hidden){butten.hidden = NO} else {button.hidden = YES} – 2014-11-05 15:18:53