如何在相应部分下实施日历?

时间:2018-06-16 00:51:58

标签: ios swift

我正在使用swift并尝试开发学校应用。但是,我有点失落。我使用以下代码制作了部分。如何在相应的“日历”部分下实施日历?我使用UITableViewController创建了不同的部分。下面发布的是代码。

ViewController.swift

import UIKit

class ViewController: UITableViewController {


    let School = "School"
    let sections = [
        "News", "Calendar", "iMotivated"
    ]

    override func viewDidLoad() {
        super.viewDidLoad()
         self.tableView.separatorStyle = UITableViewCellSeparatorStyle.none

        navigationItem.title = "school's owls"
       navigationController?.navigationBar.prefersLargeTitles = true

        tableView.register(UITableViewCell.self, forCellReuseIdentifier: School)

    }

        override func tableView(_ tableVIew: UITableView, numberOfRowsInSection section: Int) -> Int {
return 3
        }


    override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: School, for: indexPath)

        let seeingSections = self.sections[indexPath.row]
        cell.textLabel?.text = seeingSections

        return cell
    }



    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


}

AppDelegate.swift

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

    var window: UIWindow?


    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.

        window = UIWindow()
        window?.makeKeyAndVisible()

        let navController = UINavigationController(rootViewController: ViewController())
        window?.rootViewController = navController
        return true
    }

    func applicationWillResignActive(_ application: UIApplication) {
        // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
        // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
    }

    func applicationDidEnterBackground(_ application: UIApplication) {
        // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
        // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
    }

    func applicationWillEnterForeground(_ application: UIApplication) {
        // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
    }

    func applicationDidBecomeActive(_ application: UIApplication) {
        // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
    }

    func applicationWillTerminate(_ application: UIApplication) {
        // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
    }


}

1 个答案:

答案 0 :(得分:0)

如果您的问题是关于在您的部分中选择行,请使用以下方法:

table(_:didSelectRowAt:)

建议:

  • 发布问题时,请尽可能保持通用,并非所有用户都能理解您的上下文/应用。

  • 示例:日历是您的应用特有的内容,因此请将其指定为部分。