Toolbar bar button item not working properly in SplitViewController

老子叫甜甜 提交于 2019-12-12 01:49:25

问题


I'm having a weird problem that is similar to this post or this question. My toolbar's far left bar button item's touch censor is off place. In my case this only happens when I add toolbar in DetailViewController in SplitViewController and run it on the iPhone.

Red field is the off place touch censor for the item button.

I've tried many things and those are the things that I found out. I'm using Xcode 6.

  • It only happens when toolbar is in DetailViewController of SVC
  • It only happens when you run it on iPhone and not iPad
  • It only happens when it's constrained to the bottom of the DetailViewController
  • It only happens to the button on the far left of the toolbar

Has anyone had the same problem before? If not, I would very much appreciate it if you could try it yourself by simply creating a new Master-Detail project and add toolbar in DetailViewController and constrain it to the bottom and run it on the iPhone simulator or a device. Please share if it causes a same problem. There doesn't seem to be any clear answer to this so I'm wondering if there's a issue with the Xcode. Only solution I came up with is to use tab bar instead. Please share your thoughts or solution on this.

Edit:

I've connected the Item button to IBAction and it does get triggered when I touch on Item. I thought it was not working because it doesn't give the flash animation unless I touch the red field. IBAction gets called but it still doesn't give the flash animation unless I touch on the red field. And touch censor field for the item button seems too large.


回答1:


I've also found out that I cannot change the title of this button in code with method like self.itemButton.title = @"Changed Title";, but I solved this by switching between two buttons.

- (IBAction)editAction:(id)sender {
    [self.toolBar setItems:@[self.doneButton]];
}

- (IBAction)doneAction:(id)sender {
    [self.toolBar setItems:@[self.editButton]];
}

Update:

This issue has been resolved in Xcode 6.2.



来源:https://stackoverflow.com/questions/28684882/toolbar-bar-button-item-not-working-properly-in-splitviewcontroller

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!