我是IOS中的新成员。当我点击以下按钮登录:从ios中的另一个弹出按钮执行弹出式菜单
我使用这个代码来生成一个弹出:
- (UIView *)createLoginView
{
UIView *alertView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 130)];
UITextField *email = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 280, 50)];
email.tag=420;
email.layer.cornerRadius = 5;
[email setTag:99];
[email setTextAlignment:NSTextAlignmentCenter];
[email setKeyboardType:UIKeyboardTypeEmailAddress];
[email setPlaceholder:@"Email"];
[email setBackgroundColor:[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0]];
[email setReturnKeyType:UIReturnKeyNext];
[email setAutocorrectionType:UITextAutocorrectionTypeNo];
UITextField *pass = [[UITextField alloc] initWithFrame:CGRectMake(10, 70, 280, 50)];
pass.layer.cornerRadius = 5;
[pass setTag:100];
[pass setTextAlignment:NSTextAlignmentCenter];
[pass setSecureTextEntry:YES];
[pass setPlaceholder:@"Password"];
[pass setBackgroundColor:[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0]];
[pass setReturnKeyType:UIReturnKeyGo];
[alertView addSubview:email];
[alertView addSubview:pass];
return alertView;
}
登录弹出是否工作正常,但当我点击'忘记'?弹出的按钮,忘记密码弹出窗口不显示。这里是忘记密码弹出的代码。
- (UIView *)createForgotPasswordView
{
UIView *alertView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 300, 130)];
UITextField *email = [[UITextField alloc] initWithFrame:CGRectMake(10, 10, 280, 50)];
email.layer.cornerRadius = 5;
[email setTag:22];
[email setTextAlignment:NSTextAlignmentCenter];
[email setKeyboardType:UIKeyboardTypeEmailAddress];
[email setPlaceholder:@"Email"];
[email setBackgroundColor:[UIColor colorWithRed:243/255.0 green:243/255.0 blue:243/255.0 alpha:1.0]];
[email setReturnKeyType:UIReturnKeyNext];
[email setAutocorrectionType:UITextAutocorrectionTypeNo];
[alertView addSubview:email];
return alertView;
}
而且我使用它像:
- (IBAction)LogInClick:(UIButton *)sender {
IOS7AlertView *applyMsg = [[IOS7AlertView alloc] init];
[applyMsg setContainerView:[self createLoginView]];
[applyMsg setButtonTitles:[NSMutableArray arrayWithObjects:@"Forgot?", @"Login", nil]];
[applyMsg setOnButtonTouchUpInside:^(IOS7AlertView *alertView, int buttonIndex) {
if(buttonIndex==0)
{
[alertView close];
NSLog(@"Forgot Section");
IOS7AlertView *applyPop = [[IOS7AlertView alloc] init];
[applyPop setParentView:[self createForgotPasswordView]];
[applyPop setButtonTitles:[NSMutableArray arrayWithObjects:@"Next", @"Cancel", nil]];
}
}];
但问题是,在下一个弹出显示不出来?问题是什么?请帮忙。
请注意,通过iOS 7,你不应该再添加子视图'UIAlertView'。从文档:'UIAlertView'类旨在按原样使用,不支持子类。该类的视图层次结构是私有的,不能修改。 – rckoenes 2014-09-19 08:59:18
@rckoenes我不得不说'UIAlertView'我在哪里是'UIAlertView'的子类,我更关心'IOS7AlertView'背后的代码。我实际上看不到这个代码的目的,因为他们没有做任何'UIAlertView'已经为他们做的事情。 – Popeye 2014-09-19 09:16:43
@Popeye你是完全正确的,没有必要自己添加'UITextField'。我的评论更多地指向文档中声明de视图层次是私有的部分。因此插入你自己的观点可能会搞砸了。 – rckoenes 2014-09-19 09:27:13