Ios 处理我的故事板的片段和下一个屏幕

Ios 处理我的故事板的片段和下一个屏幕,ios,xcode,swift,Ios,Xcode,Swift,我在登录时使用此代码来提醒用户,但提醒消息将弹出到我的下一个看到。。。 我希望在登录页面中显示该警报,但它不应显示我的下一个屏幕如何执行该操作?只需执行此操作 if (self.txtusername.text.isEmpty) { (UIAlertView(title: "Fields cant be empty", message: "Please Enter username and password", delegate: nil, cancelButtonTitle:

我在登录时使用此代码来提醒用户,但提醒消息将弹出到我的下一个看到。。。 我希望在登录页面中显示该警报,但它不应显示我的下一个屏幕如何执行该操作?

只需执行此操作

if (self.txtusername.text.isEmpty)
{
    (UIAlertView(title: "Fields cant be empty", message: "Please Enter username and password",
     delegate: nil, cancelButtonTitle: "OK").show())
     self.dismissViewControllerAnimated(true, completion: nil)
}
else if (range==nil)
{
    (UIAlertView(title: "Invalid Email Id", message: "Type mail id like xxx@yyy.zzz", delegate: nil, cancelButtonTitle: "OK").show())
    self.dismissViewControllerAnimated(true, completion: nil)
}
可能很容易帮到你

享受编码的乐趣

试试这段代码

if(responseData != "\"Valid user\"")
                {
                var alertView:UIAlertView = UIAlertView()
                    alertView.title = "Failed"
                    alertView.message = responseData
                    alertView.delegate = self
                    alertView.addButtonWithTitle("OK")
                    alertView.show()
                    //self.dismissViewControllerAnimated(true, completion: nil)
                    //let vc = LoginController()

                    return;
                }

点击alertview的按钮点击事件打开新屏幕。你能详细说明一下吗?这个函数的其余代码呢?可能问题不在这段代码中如果(self.txtusername.text.isEmpty){(UIAlertView(标题:“字段不能为空”,消息:“请输入用户名和密码”,委托:无,取消按钮提示:“确定”).show())self.dismissViewControllerAnimated(真,完成:无)如果用户在登录时没有提供凭据,我会显示此警报消息,但该警报会出现在我的主页上,应该出现在登录时,对吗?我没有收到这件事,你也会通过评论告诉他…你必须解释此代码的含义…只是复制和粘贴不是stackoverflow的全部内容如果你执行
self.dIsMissisViewControlleranimated(true,completion:nil)
在您的条件调用中执行此操作,则您当前的视图将被关闭(表示已解除),并导航到当前视图的父视图。我不获取视图配置。请使用完整函数获取更多详细信息。从何处获取参数?将完整函数放置在调用segue的位置。这样我可以更好地帮助您
  UIAlertView *alert = [[UIAlertView alloc] initWithTitle: @"Fields cant be empty"
                                                    message:@"Please Enter username and password"
                                                   delegate:nil
                                          cancelButtonTitle:@"Cancel"
                                          otherButtonTitles:@"OK", nil];
[alert show];

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex (NSInteger)buttonIndex** 
{
    if (buttonIndex == 0){
         //your code...
    }
    else{
         NSLog(@"cancel");
    }
}