gpt4 book ai didi

ios - 继承 UIVisualEffectView 的问题

转载 作者:行者123 更新时间:2023-12-01 16:40:12 25 4
gpt4 key购买 nike

我正在自定义 Parse 登录 View ,并使用库创建了模糊的背景,但现在我可以使用 UIVisualEffectView。因为我有一个类(class)作为 PFLoginViewController 的代表我决定继承 UIVisualEffectView 并将其作为我的代表。问题是我的所有登录 View 都没有显示。我知道我的框架设置正确。这是我的代码,可以更好地了解我在说什么。

-(id)initWithEffect:(UIVisualEffect *)effect {

self = [super initWithEffect:effect];

[self setUpUserViews];

return self;

}

- (void)setUpUserViews {

NSLog(@"Setting Up View");

CGRect size = CGRectMake(0, 0, self.frame.size.width, self.frame.size.height);

//Initialize login and sign up views
_loginView = [[PFLogInViewController alloc] init];
_signUpView = [[PFSignUpViewController alloc] init];

//Set their delegates to this view controller
[_loginView setDelegate:self];
[_signUpView setDelegate:self];

//Set fields for sign up view
[_signUpView setFields:PFSignUpFieldsEmail | PFSignUpFieldsUsernameAndPassword | PFSignUpFieldsSignUpButton];

//Set sign up view for login view
[_loginView setSignUpController:_signUpView];

//Set up login view
_loginView.view.frame = size;

_loginView.view.backgroundColor = [UIColor clearColor];

[_loginView.logInView setLogo:[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"banner.png"]]];

//Set Login Button
[_loginView.logInView.logInButton setBackgroundImage:[UIImage imageNamed:@"orange.png"] forState:UIControlStateNormal];
[_loginView.logInView.logInButton setBackgroundImage:[UIImage imageNamed:@"orangeDown.png"] forState:UIControlStateHighlighted];

//Set login text color
[_loginView.logInView.logInButton setTitleColor:[UIColor orangeColor] forState:UIControlStateNormal];
[_loginView.logInView.logInButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];

//Set sign up button
[_loginView.logInView.signUpButton setBackgroundImage:[UIImage imageNamed:@"green.png"] forState:UIControlStateNormal];
[_loginView.logInView.signUpButton setBackgroundImage:[UIImage imageNamed:@"greenDown.png"] forState:UIControlStateHighlighted];

//Set sign up button text color
[_loginView.logInView.signUpButton setTitleColor:[UIColor colorWithRed:0.0 green:1.0 blue:0.0 alpha:0.6] forState:UIControlStateNormal];
[_loginView.logInView.signUpButton setTitleColor:[UIColor whiteColor] forState:UIControlStateHighlighted];

//Set dismiss button
[_loginView.logInView.dismissButton setImage:nil forState:UIControlStateNormal];
[_loginView.logInView.dismissButton setImage:nil forState:UIControlStateHighlighted];

[_loginView.logInView.dismissButton setBackgroundImage:nil forState:UIControlStateHighlighted];
[_loginView.logInView.dismissButton setBackgroundImage:nil forState:UIControlStateNormal];

[_loginView.logInView.dismissButton setBackgroundImage:[UIImage imageNamed:@"dismiss.png"] forState:UIControlStateHighlighted];
[_loginView.logInView.dismissButton setBackgroundImage:[UIImage imageNamed:@"dismiss.png"] forState:UIControlStateNormal];

//Set forgotten button
[_loginView.logInView.passwordForgottenButton setImage:[UIImage imageNamed:@"forgot.png"] forState:UIControlStateNormal];
[_loginView.logInView.passwordForgottenButton setImage:[UIImage imageNamed:@"forgot.png"] forState:UIControlStateHighlighted];

[_loginView.logInView.passwordForgottenButton setBackgroundImage:nil forState:UIControlStateNormal];
[_loginView.logInView.passwordForgottenButton setBackgroundImage:nil forState:UIControlStateHighlighted];

//Use custom method for showing sign up view
[_loginView.logInView.signUpButton removeTarget:nil action:NULL forControlEvents:UIControlEventAllEvents];

[_loginView.logInView.signUpButton addTarget:self action:@selector(customViewMethod) forControlEvents:UIControlEventTouchUpInside];

//Set up sign up view
_signUpView.signUpView.backgroundColor = [UIColor clearColor];

//Set sign up button
[_signUpView.signUpView.signUpButton setImage:[UIImage imageNamed:@"green.png"] forState:UIControlStateNormal];
[_signUpView.signUpView.signUpButton setImage:[UIImage imageNamed:@"greenPress.png"] forState:UIControlStateHighlighted];

[_signUpView.signUpView.signUpButton setBackgroundImage:nil forState:UIControlStateNormal | UIControlStateHighlighted];

//Present login view
[self.contentView addSubview:_loginView.view];
}

这是我得到的截图。左上角有一个 X。这是登录 View 的一部分:

enter image description here

这是它应该是什么样子的屏幕截图:

enter image description here

最佳答案

问题已解决。问题是事情被过早地从内存中释放,导致出现 nil代表。

关于ios - 继承 UIVisualEffectView 的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25071925/

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