var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let tabBarController = UITabBarController()
let settingStoryboard = UIStoryboard(name: "Setting", bundle: nil)
let toDoListStoryboard = UIStoryboard(name: "ToDoList", bundle: nil)
let homeStoryboard = UIStoryboard(name: "Home", bundle: nil)
let eventListStoryboard = UIStoryboard(name: "EventList", bundle: nil)
let activityStoryboard = UIStoryboard(name: "Activity", bundle: nil)
let settingVC = settingStoryboard.instantiateViewController(withIdentifier: "Setting") as! SettingViewController
let toDoListVC = toDoListStoryboard.instantiateViewController(withIdentifier: "ToDoList") as! ToDoListViewController
let homeVC = homeStoryboard.instantiateViewController(withIdentifier: "Home") as! HomeViewController
let eventListVC = eventListStoryboard.instantiateViewController(withIdentifier: "EventList") as! EventListViewController
let activityVC = activityStoryboard.instantiateViewController(withIdentifier: "Activity") as! ActivityViewController
let vcData: [(UIViewController, UIImage, UIImage)] = [
(settingVC, UIImage(named: "SettingIcon")!, UIImage(named: "SettingSelectedIcon")!),
(toDoListVC, UIImage(named: "ToDoIcon")!, UIImage(named: "ToDoSelectedIcon")!),
(homeVC, UIImage(named: "HomeIcon")!, UIImage(named: "HomeSelectedIcon")!),
(eventListVC, UIImage(named: "EventIcon")!, UIImage(named: "EventSelectedIcon")!),
(activityVC, UIImage(named: "ActivityIcon")!, UIImage(named: "ActivitySelectedIcon")!)
]
let vcs = vcData.map { (vc, image, selectedImage) -> UINavigationController in
let nav = UINavigationController(rootViewController: vc)
nav.tabBarItem.image = image.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
nav.tabBarItem.selectedImage = selectedImage.withRenderingMode(UIImage.RenderingMode.alwaysOriginal)
nav.tabBarItem.imageInsets = UIEdgeInsets(top: 7, left: 0, bottom: -5, right: 0)
return nav
}
tabBarController.viewControllers = vcs
tabBarController.tabBar.isTranslucent = false
tabBarController.tabBar.barTintColor = UIColor(red: 19/255, green: 41/255, blue: 77/255, alpha: 1)
UINavigationBar.appearance().barTintColor = UIColor(red: 19/255, green: 41/255, blue: 77/255, alpha: 1)
UINavigationBar.appearance().isTranslucent = false
window?.rootViewController = tabBarController
print(Realm.Configuration.defaultConfiguration.fileURL!)
return true
}
在上面显示的代码中,当应用程序运行rootviewcontroller时,它是添加到堆栈中的第一个视图。您如何将rootviewcontroller更改为HomeViewController而不先初始化homeviewcontroller。
答案 0 :(得分:2)
只需添加
@RequestMapping(value = "/delete/{id}")
private String deleteStudent(@PathVariable(name = "id") String id){
System.out.println("Student_Id : "+id);
return "redirect:/display";
}
一行之后
def build_item(fields, response):
item = {}
for key, value in fields.items():
if key in item:
continue
for extractor in value:
if extractor.get("method") == "xpath":
data = response.xpath(extractor.get("expression")).re(extractor.get("re"))
if data:
item[key] = data
break
# …
return item
答案 1 :(得分:0)
您可以随时通过以下方式更改RootViewController
let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
let homeViewController = storyboard.instantiateViewController(withIdentifier: "HomeViewController") as! HomeViewController
UIApplication.shared.delegate?.window??.rootViewController = homeViewController