在网上下了一个弹出一个窗口的例子,如下
#import "UIDialogWindow.h"@implementation UIDialogWindow@synthesize view;
@synthesize superView;
@synthesize backgroundView;
@synthesize backgroundImage;
-(UIDialogWindow *)initWithView:(UIView *)aView:(NSInteger)degree
{
if (self=[super init]) {
//内容view
self.view=aView;
// NSLog(@"initWithView");
[self setFrame:[[UIScreen mainScreen]bounds]];
self.windowLevel=UIWindowLevelStatusBar;
self.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
//根view
UIView *sv=[[UIView alloc] initWithFrame:[self bounds]];
self.superView=sv;
[superView setAlpha:0.0f];
[self addSubview:superView];
[sv release];
CGFloat d=-7.0f;
UIView *bv=[[UIView alloc] initWithFrame:CGRectInset(CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height),d,d)];
self.backgroundView=bv;
//圆角图片背景view
UIImageView *bi=[[UIImageView alloc] initWithImage:[[Global pngWithPath:@"ipad_casino_limit"]stretchableImageWithLeftCapWidth:0.8 topCapHeight:0.5]];
self.backgroundImage=bi;
[backgroundImage setFrame:[backgroundView bounds]];
[backgroundView insertSubview:backgroundImage atIndex:0];
[backgroundView setCenter:CGPointMake(superView.bounds.size.width/2, superView.bounds.size.height/2)];
backgroundView.transform = CGAffineTransformIdentity;
backgroundView.transform = CGAffineTransformMakeRotation(degreesToRadians(degree));
[superView addSubview:backgroundView];
CGRect frame=CGRectInset([backgroundView bounds], -1*d, -1*d);
//显示内容view
[self.view setCenter:CGPointMake(superView.bounds.size.width/2, superView.bounds.size.height/2)];
[backgroundView addSubview:self.view];
[self.view setFrame:frame];
isClose=NO;
[bv release];
[bi release];
}
return self;
}
//显示弹出窗口
-(void)show
{
[self makeKeyAndVisible];
[superView setAlpha:1.0f];
}
-(void)dialogIsRemoved
{
// NSLog(@"dialogIsRemoved ");
isClose=YES;
[view removeFromSuperview];
view=nil;
[backgroundView removeFromSuperview];
backgroundView=nil;
[superView removeFromSuperview];
superView=nil;
[self removeFromSuperview];
[self setAlpha:0.0f];
self = nil;
}-(void)close
{
[self dialogIsRemoved];
}
@end
此类地址如下
http://www.cnblogs.com/hll2008/archive/2011/05/30/2063577.html当利用此类创建了一个弹出窗口,然后弹出窗口上面有一个BUTTON,点击此BUTTON,关闭这个弹出的窗口,
关闭窗口调用的是dialogIsRemoved
然后此弹出的窗口被关闭,但是我将dialogIsRemoved中的[self setAlpha:0.0f];注释掉,调用dialogIsRemoved的时候弹出的窗体内容被移除,这个时候只剩下一个黑色透明的背景,也看得到父VIEW,是整个弹出的窗体没有移除成功吗??
黑色透明的背景是在self.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];设置的
dialogIsRemoved的是所有的VIEW我都移除了,怎么还会有一个黑色的背景在呢?
关闭的时候如果不加上[self setAlpha:0.0f];那么父VIEW上面的所有按钮都按不了,父VIEW上好像还有一层黑色的VIEW没有移除
#import "UIDialogWindow.h"@implementation UIDialogWindow@synthesize view;
@synthesize superView;
@synthesize backgroundView;
@synthesize backgroundImage;
-(UIDialogWindow *)initWithView:(UIView *)aView:(NSInteger)degree
{
if (self=[super init]) {
//内容view
self.view=aView;
// NSLog(@"initWithView");
[self setFrame:[[UIScreen mainScreen]bounds]];
self.windowLevel=UIWindowLevelStatusBar;
self.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];
//根view
UIView *sv=[[UIView alloc] initWithFrame:[self bounds]];
self.superView=sv;
[superView setAlpha:0.0f];
[self addSubview:superView];
[sv release];
CGFloat d=-7.0f;
UIView *bv=[[UIView alloc] initWithFrame:CGRectInset(CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height),d,d)];
self.backgroundView=bv;
//圆角图片背景view
UIImageView *bi=[[UIImageView alloc] initWithImage:[[Global pngWithPath:@"ipad_casino_limit"]stretchableImageWithLeftCapWidth:0.8 topCapHeight:0.5]];
self.backgroundImage=bi;
[backgroundImage setFrame:[backgroundView bounds]];
[backgroundView insertSubview:backgroundImage atIndex:0];
[backgroundView setCenter:CGPointMake(superView.bounds.size.width/2, superView.bounds.size.height/2)];
backgroundView.transform = CGAffineTransformIdentity;
backgroundView.transform = CGAffineTransformMakeRotation(degreesToRadians(degree));
[superView addSubview:backgroundView];
CGRect frame=CGRectInset([backgroundView bounds], -1*d, -1*d);
//显示内容view
[self.view setCenter:CGPointMake(superView.bounds.size.width/2, superView.bounds.size.height/2)];
[backgroundView addSubview:self.view];
[self.view setFrame:frame];
isClose=NO;
[bv release];
[bi release];
}
return self;
}
//显示弹出窗口
-(void)show
{
[self makeKeyAndVisible];
[superView setAlpha:1.0f];
}
-(void)dialogIsRemoved
{
// NSLog(@"dialogIsRemoved ");
isClose=YES;
[view removeFromSuperview];
view=nil;
[backgroundView removeFromSuperview];
backgroundView=nil;
[superView removeFromSuperview];
superView=nil;
[self removeFromSuperview];
[self setAlpha:0.0f];
self = nil;
}-(void)close
{
[self dialogIsRemoved];
}
@end
此类地址如下
http://www.cnblogs.com/hll2008/archive/2011/05/30/2063577.html当利用此类创建了一个弹出窗口,然后弹出窗口上面有一个BUTTON,点击此BUTTON,关闭这个弹出的窗口,
关闭窗口调用的是dialogIsRemoved
然后此弹出的窗口被关闭,但是我将dialogIsRemoved中的[self setAlpha:0.0f];注释掉,调用dialogIsRemoved的时候弹出的窗体内容被移除,这个时候只剩下一个黑色透明的背景,也看得到父VIEW,是整个弹出的窗体没有移除成功吗??
黑色透明的背景是在self.backgroundColor=[UIColor colorWithRed:0 green:0 blue:0 alpha:0.7];设置的
dialogIsRemoved的是所有的VIEW我都移除了,怎么还会有一个黑色的背景在呢?
关闭的时候如果不加上[self setAlpha:0.0f];那么父VIEW上面的所有按钮都按不了,父VIEW上好像还有一层黑色的VIEW没有移除
点击这个弹出VIEW上面的BUTTON后跳转到另外一个VIEW,这个VIEW中有一个WEBVIEW控件,里面加载了一个网页,点击网页上面的SELECT(下拉列表控件)的时候点击不了,如果不通过弹出的VIEW,直接跳转到WEBVIEW控件的VIEW ,SELECT是可以点击的,里面的内容一点击就能打开
不是是还是这个弹出的VIEW中创建的VIEW没有移除干净呢??