0

I wanna transition screens in my app but it cannot be done. I used TabBarController and I made Tab1 item and Tab2 item. When I tapped Tab2 in my simulator, my app dropped.

import UIKit
import SwiftyJSON

class ViewController: UIViewController {

    @IBOutlet var KenshinPic: UITabBarItem!
    override func viewDidLoad() {
        super.viewDidLoad()
        // Do any additional setup after loading the view, typically from a nib.
    }

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


extension ViewController : UITabBarControllerDelegate {


    public func tabBarController(tabBarController: UITabBarController, viewController: UIViewController) -> Bool {
        if(viewController.restorationIdentifier == "first") {
            self.tabBarController!.setViewControllers([KenshinSendController() , KenshinViewController()], animated: false);


            let items = self.tabBarController!.tabBar.items;
            items![1].title = "Second";

            items![0].title = "First";

            return false;
        }

        return true;
    }
}


Below sentences didn't be called in Xcode when I run my app.

    enter code here
     self.tabBarController!.setViewControllers([KenshinSendController() , KenshinViewController()], animated: false);

Error message was 'signal SIGABRT'

in class AppDelegate: UIResponder, UIApplicationDelegate {

of AppDelegate file.

What shoud I do?

Amanpreet
  • 1,301
  • 3
  • 12
  • 29
Rose2017
  • 79
  • 11
  • What function you is implementing the UITabBarControllerDelegate? The function you wrote didn't match any functions of UITabBarControllerDelegate. – bubuxu Jan 01 '17 at 05:19
  • And, what kind of transition you are trying to do? Check this post: http://stackoverflow.com/a/5180104/4045472 – bubuxu Jan 01 '17 at 05:23
  • I thought ViewController have to be inheritanced Delegate(=UITabBarControllerDelegate).Im a beginner,so my idea may be wrong . – Rose2017 Jan 01 '17 at 08:07
  • transition means ,for example, when I touched Item2 tab,I can see a ViewController that connect to Item2 tab.It can be seen in normal apps many times.In Facebook apps, when I touched Friends' request tab,I can see its page. – Rose2017 Jan 01 '17 at 08:10
  • I suggest you to create a new project, by selecting the **Tabbed Application** template, then you will be able to understand how to do. For more information, check this: https://developer.apple.com/reference/uikit/uitabbarcontroller – bubuxu Jan 01 '17 at 08:16

0 Answers0