implement a simple back button swift ios

时间:2016-02-12 22:08:52

标签: ios swift

I have a navigation bar placed directly on my scene. On his I have a navigation item. I can successfully change title on it.

Now I want a back button to appear - I do not need any customization at present, just the ability to catch the click and default ios look for whatever plaform the app is running (Since Swift that is ios7+).

In viewDidLoad() I have written

int read_single_bit(unsigned char* buffer, unsigned int index)

In outletCatalogNavItem.backBarButtonItem = UIBarButtonItem(title: "test", style .plain, target: self, action: "ownbackNavigationFuncCode"); *ViewDidAppear()* is non-nil

Note: I am not using any shared navigation control across scenes in my storyboard - nor wish to at this point since I am porting an app from another tool/language which has its own navigation/stack logic already (meaning I handle switching and navigation myself in code)

2 个答案:

答案 0 :(得分:0)

将视图控制器嵌入UINavigationController。当您push/segue到新视图控制器时,您要查找的< Back按钮将显示在左侧。

答案 1 :(得分:0)

let backItem = UIBarButtonItem()
backItem.title = "Back"
navigationItem.backBarButtonItem = backItem