UIAlertView显示错误
事情是这样的...
我正在尝试以编程方式显示带有多个子视图的 UIAlertView 。它是使用我的 UISignInView 类(具有所需协议的 UIViewController)从另一个 UIAlertView 调用的,
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
UISignInView *signinview;
switch (buttonIndex) {
case 0:
break;
case 1:
signinview = [UISignInView new];
[signinview addLoginPopUp:self:0];
break;
default:
break;
}
并且使用此函数创建的:
- (void)addLoginPopUp:(id) sender:(int) error{
NSString * Msg;
double Yposition;
switch (error) {
case 0:
Msg = @"\n\n\n\n\n\n\n\n\n\n";
Yposition = 45.0;
break;}
loginPopUp = [[UIAlertView alloc] initWithTitle:@"Inscription"
message:Msg
delegate:self
cancelButtonTitle:@"Annuler"
otherButtonTitles:nil];
[loginPopUp addButtonWithTitle:@"S'inscrire"];
[loginPopUp show];
//Adding 3 UITextFields
login = nil;
login = [[UITextField alloc] initWithFrame:CGRectMake(10.0, Yposition, 264.0, 30.0)];
[loginPopUp addSubview:login];
password = nil;
password = [[UITextField alloc] initWithFrame:CGRectMake(10.0, Yposition + 36, 264.0, 30.0)];
[loginPopUp addSubview:password];
repeat_password = nil;
repeat_password = [[UITextField alloc] initWithFrame:CGRectMake(10.0, Yposition + 36 + 36, 264.0, 30.0)];
[loginPopUp addSubview:repeat_password];
//Adding 2 UISwitch
accept_appli= [[UISwitch alloc] initWithFrame:CGRectMake(179.0, Yposition + 36 + 36 +36, 64, 30.0)];
[accept_appli setOn:FALSE];
[loginPopUp addSubview:accept_appli];
accept_part = [[UISwitch alloc] initWithFrame:CGRectMake(179.0, Yposition + 36 + 36 +36 + 33, 64, 30.0)];
[accept_part setOn:FALSE];
[loginPopUp addSubview:accept_part];
[loginPopUp release];
}
结果是 UIAlertView 标签就像滚动模式一样,并且按钮不够“向下”。
我首先想到了“\n”限制,但如果公式出现任何问题,这个完全相同的 UIAlertView 将从请求完成函数中回调,除了一切都显示良好之外
有什么想法吗?我已经处理这个问题有一段时间了...
感谢您的帮助!
Here is the thing...
I'm trying to programmatically display an UIAlertView with several subviews. It's being called from another UIAlertView using my UISignInView class (UIViewController with needed protocols)
-(void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{
UISignInView *signinview;
switch (buttonIndex) {
case 0:
break;
case 1:
signinview = [UISignInView new];
[signinview addLoginPopUp:self:0];
break;
default:
break;
}
And it's created using this function:
- (void)addLoginPopUp:(id) sender:(int) error{
NSString * Msg;
double Yposition;
switch (error) {
case 0:
Msg = @"\n\n\n\n\n\n\n\n\n\n";
Yposition = 45.0;
break;}
loginPopUp = [[UIAlertView alloc] initWithTitle:@"Inscription"
message:Msg
delegate:self
cancelButtonTitle:@"Annuler"
otherButtonTitles:nil];
[loginPopUp addButtonWithTitle:@"S'inscrire"];
[loginPopUp show];
//Adding 3 UITextFields
login = nil;
login = [[UITextField alloc] initWithFrame:CGRectMake(10.0, Yposition, 264.0, 30.0)];
[loginPopUp addSubview:login];
password = nil;
password = [[UITextField alloc] initWithFrame:CGRectMake(10.0, Yposition + 36, 264.0, 30.0)];
[loginPopUp addSubview:password];
repeat_password = nil;
repeat_password = [[UITextField alloc] initWithFrame:CGRectMake(10.0, Yposition + 36 + 36, 264.0, 30.0)];
[loginPopUp addSubview:repeat_password];
//Adding 2 UISwitch
accept_appli= [[UISwitch alloc] initWithFrame:CGRectMake(179.0, Yposition + 36 + 36 +36, 64, 30.0)];
[accept_appli setOn:FALSE];
[loginPopUp addSubview:accept_appli];
accept_part = [[UISwitch alloc] initWithFrame:CGRectMake(179.0, Yposition + 36 + 36 +36 + 33, 64, 30.0)];
[accept_part setOn:FALSE];
[loginPopUp addSubview:accept_part];
[loginPopUp release];
}
And the result is that the UIAlertView label goes like in a scrolling mode, and the buttons are not "down" enough.
I first thought of a "\n" limit but if anything goes wrong with the formular, this exact same UIAlertView is called back from the request done function, except everything is well displayed
Any Idea? I've been dealing with this for a while now...
Thanks for helping!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我终于找到了一种方法来防止这种情况发生...
我没有在 ViewDidLoad 中添加子视图,而是将它们添加到 ViewWillAppear 函数中。
我猜这是一个错误......并且在我之前的代码中,视图是在错误的时刻添加的。
希望它会有所帮助!
I finally found out a way to prevent this from appenning...
Instead of adding the subviews in ViewDidLoad I added them in the ViewWillAppear function.
I guess its kind of a bug... and that in my previous code, the views were added at a wrong moment.
Hope it'll help!