我試圖觸發添加兩個子視圖時,一個條形按鈕被點擊。但添加子視圖工作得很好,但是當我嘗試刪除子視圖時,它不起作用。刪除條形按鈕被點擊時的子視圖
這裏是我實現
-(IBAction)showPopover:(id)sender{
UIView *popoverView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 100)];
UIView *popoverViewBackground = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 1000)];
popoverView.alpha = 0.0;
popoverView.layer.cornerRadius = 2;
popoverView.layer.borderWidth = 0.1f;
popoverView.layer.backgroundColor = [UIColor whiteColor].CGColor;
popoverView.layer.masksToBounds = YES;
popoverViewBackground.layer.backgroundColor= [UIColor blackColor].CGColor;
if (popoverCount == 0) {
[self.view addSubview:popoverViewBackground];
[self.view addSubview:popoverView];
popoverCount = 1;
}else if (popoverCount ==1){
[popoverView removeFromSuperview];
[popoverViewBackground removeFromSuperview];
popoverCount = 0;
}
[popoverViewBackground setAlpha:0.5];
[popoverView setAlpha:1.0];
}
非常感謝。我不知道爲什麼我沒有想到這一點。 – Jonathan 2013-03-05 06:15:04
是的,我會的。只要stackoverflow讓我接受它:P – Jonathan 2013-03-05 06:16:28
我可以請你打擾最後一件事嗎?有沒有辦法將一個下拉和捲起動畫連接到我的popoverview?比如谷歌加在他們的應用程序呢? – Jonathan 2013-03-05 06:23:30