测试环境: xcode Version 4.6 (4H127) , ios6.1
------
// self 是 LoginView ,是加载xib文件生成的:
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"LoginView"
owner:nil options:nil];
LoginView *viewLogin = (LoginView*)[[nibContents objectAtIndex:0] retain];
viewLogin.frame = CGRectMake(0, 0, menuWidth, menuHeight);
viewLogin.delegate = self;
view = viewLogin;
---------
// addsubview调用 加载xib文件生成的view :sub view的 的按钮点击事件等可以响应
-(void) show_setViewOfLogin:(BOOL) isShow isWithAnimation:(BOOL) isWithAnimation
{
if (isShow) {
if (setViewOfLogin == nil) {
NSArray *nibContents = [[NSBundle mainBundle] loadNibNamed:@"SetViewOfLogin"
owner:nil options:nil];
setViewOfLogin = (SetViewOfLogin*)[[nibContents objectAtIndex:0] retain];
setViewOfLogin.frame = CGRectMake((1024- 800)/2.0, (748 - 220)/2.0, 800, 220);
setViewOfLogin.delegate = self;
[ShadowHandle addShadow:setViewOfLogin color:[UIColor blackColor]];
}
if ([setViewOfLogin superview] == nil) {
[self addSubview:setViewOfLogin];
}
setViewOfLogin.hidden = NO;
}
else
{
if (setViewOfLogin != nil) {
setViewOfLogin.hidden = YES;
}
}
}
//
-(void) show_helpSystemView:(BOOL) isShow isWithAnimation:(BOOL) isWithAnimation
{
if (isShow) {
if (helpSystemView == nil) {
helpSystemView = [[HelpSystemView alloc] initWithFrame:CGRectMake(0, 0, 1024, 748)];
helpSystemView.delegate = self;
}
if ([helpSystemView superview] == nil) {
[self.superview addSubview:helpSystemView]; // 这样可以响应, self.superview 没用 xib 生成;
// 如果是这样 用self 加入子视图的 则 会出现刚才说的 情况
[self addSubview:helpSystemView];
}
helpSystemView.hidden = NO;
}
else
{
if (helpSystemView != nil) {
helpSystemView.hidden = YES;
}
}
}