Add target to stock back button in navigationBar

前端 未结 6 1938
我在风中等你
我在风中等你 2021-01-14 18:48

I am setting the values of the title and back button in the UINavigationBar as follows:

self.navigationItem.title = @\"Post\";
[self.navigationC         


        
6条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-14 19:13

    Yo can't add target to back button. You can add leftbarbutton item and addtarget to it.

      UIBarButtonItem *tmpButtonItem = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStylePlain target:self action:@selector(backAction:)];
     self.navigationItem.leftBarButtonItem = tmpButtonItem;
    

提交回复
热议问题