我刚刚开始学习IOS开发,我已经成功实现了SWRevealViewController,通过在线跟踪给定的教程,所有这些都按预期工作。
然后我决定添加一个登录屏幕,这是用户在运行应用程序时看到的第一个页面。我采取的步骤如下:
答案 0 :(得分:3)
<强>步骤1 强>
将您的登录VC嵌入到NavigationController。
<强>步骤-2 强>
在您的登录按钮操作上将segue类型设置为protected void Button1_Click(object sender, EventArgs e)
{
con.Open();
SqlDataReader reader;
SqlCommand cmd = new SqlCommand("select stock from Inventory, con);
cmd.CommandType = CommandType.Text;
reader = cmd.ExecuteReader();
// Data is accessible through the DataReader object here. You'll have to fill this part in
cmd.ExecuteNonQuery();
if (txtstockremove.Text <= currentStock)
{
SqlCommand cmd = new SqlCommand("update Inventory set stock= stock - '" + txtstockremove.Text + "' where model_number='" + txtmodelno.Text + "'", con);
cmd.ExecuteNonQuery();
}
else
{
Label1.Visible = true;
Label1.Text = "Stock Successfully Removed!";
}
con.Close();
GridView1.DataBind();
Label1.Visible = true;
Label1.Text = "Stock Successfully Removed!";
}
并调用
Modal
有关流程理解的目的
对于示例项目,您可以download here
答案 1 :(得分:2)
故事板安排看起来不错。我使用了SWRevealController
,如下所示:
登录后(执行登录服务或某些登录过程)写下面的代码。
此代码会将当前的rootViewController(在您的情况下为LoginViewController
)更改为SWRevealController
。这样它才会起作用。当你注销时,将rootViewController更改为LoginViewController
。
SWRevealViewController *controller = (SWRevealViewController *)[self.mainStoryboard instantiateViewControllerWithIdentifier:@"RevealViewController"];
[self.window setRootViewController:controller];
不要忘记在Storyboard中为SWRevealViewController
分配StoryboardID =“RevealViewController”。
Swift代码:
将以下功能添加到您的AppDelegate.swift
文件中:
func changeRootViewControllerToSWRevealViewController () {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let controller = storyboard.instantiateViewControllerWithIdentifier("RevealViewController")
if let window = self.window{
window.rootViewController = controller
}
}
//在您的登录按钮操作方法中调用以上函数,如下所示:
let appDelegate = UIApplication.sharedApplication().delegate as! AppDelegate
appDelegate.changeRootViewControllerToSWRevealViewController()