gpt4 book ai didi

IOS:在后台单击时删除 View

转载 作者:行者123 更新时间:2023-11-28 21:52:45 26 4
gpt4 key购买 nike

我正在做与自定义警报相关的应用程序。当我单击警报 View 上的确定按钮时,用于显示具有透明背景的警报 View 的书面代码 - 警报消失。

当我触摸透明 View 时发生同样的事情我需要帮助我的代码也在下面:

- (void)didCustomPopUpAlertLoad:(UIView *)parentView andtitle:(NSString *)strTitle {

[self setRootView:parentView];
self.lblAlertMessage.text = strTitle;

//Add alertview into transparent view to hide parent view interaction
UIView *transparentView = [[UIView alloc] initWithFrame:parentView.bounds];
[transparentView setBackgroundColor:[UIColor clearColor]];
[transparentView addSubview:self];

float x = (int)(transparentView.bounds.size.width - self.bounds.size.width)>>1;
float y = (int)(transparentView.bounds.size.height - self.bounds.size.height)>>2;
[self setFrame:CGRectMake(x, y+62, self.bounds.size.width, self.bounds.size.height)];

// [self setFrame:CGRectMake(x+10, y+62, self.bounds.size.width, self.bounds.size.height)];
[self.window addSubview:transparentView];
[self.window makeKeyAndVisible];
[[transparentView subviews]
makeObjectsPerformSelector:@selector(setUserInteractionEnabled:)
withObject:[NSNumber numberWithBool:FALSE]];


}
-(void)didCustomPopUpUnload{

[self.superview removeFromSuperview];
// Set up the fade-in animation
self.window = nil;

}

-(IBAction)didActionOkAlertPopUp:(id)sender{

[self didCustomPopUpUnload];
}

最佳答案

创建自定义透明 View 然后覆盖此方法

-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event

将您的警报 View 添加到此 View 中并将此 View 用作全屏 View 。您可以使用 event 参数来计算以了解 alertview 内部或外部的用户触摸。

关于IOS:在后台单击时删除 View ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27718004/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com