Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Plain Style unsupported in a Navigation Item" warning with my customized Bar Button Item

I drag a Round Rect Button to the position of the right Bar Button Item, and set an image to the Round Rect Button. All works well, except the warning "Plain Style unsupported in a Navigation Item". Even if i select the style of the Bar Button Item to "Bordered", warning still be there. What's the matter with Xcode 4.2? Thanks in advance!

Ps. I customized many Bar Button Items with Round Rect Button, some times Xcode 4.2 shows only one warning on a Bar Button Item, some times shows warnings on all Bar Button Items.

like image 363
lu yuan Avatar asked Jun 08 '12 09:06

lu yuan


2 Answers

I was able to remove these errors by manually editing the storyboard files and find the offending style="plain" entry on Bar Button items in the <navigationItem> element.

Changed from:

<barButtonItem key="rightBarButtonItem" style="plain" id="juB-DL-F9i"> 

To:

<barButtonItem key="rightBarButtonItem" id="juB-DL-F9i"> 

This cleared the warnings... right or wrong.

This may be a stupendous hack and the larger concern is I did not root cause it or remove the invisible bar button items from the overall document. This was after going through all the elements one by one and discovering some navigation bars were empty (without children) and likely occurred with the large amount of copy and paste (cmd+c|v) inheritance and not using duplicate (cmd+d) to build the interface. Although the source cause was not root caused, the symptom was the bar items did not show in the document "outline view" to be fixed. Interface Builder behavior strikes me as nuanced at times and an empty container where there should be something in an outline view is a smell. Well it is to me now. Sometimes deleting the offending node and rebuilding fixes the oddest issues.

WARNING: back up your storyboards before you try this... version control is your friend... I take no responsibility when your storyboard is completely hosed and wont compile. All you'll get is an "I told you so!" I learned the hard way a few times, but diligent source control saved me a headache.

EDIT: put brackets in code blocks

like image 163
Hunter-Orionnoir Avatar answered Sep 21 '22 00:09

Hunter-Orionnoir


In case you click on the warning and you don't go to the offending navigation item do the following. (visual representation of Hunter's answer with safer method from comments added in)

In the file browser right click on the storyboard and select Open As Source Code

enter image description here

In the source code page search for "plain", and find the one attached to a Navigation Item.

enter image description here

To get the name of the View, put "scene" in the search bar and click the back search arrow to search for the first instance on that tag above the navigationItem

enter image description here

Here is the name of your Scene, you can now change your Storyboard view back to Interface Builder - Storyboard with the right click method described above, and then go to select the Scene in the scene menu, and the Bar Item inside it.

enter image description here

Go to the Attributes inspector and change the style from Plain to Bordered

enter image description here

like image 35
dstudeba Avatar answered Sep 18 '22 00:09

dstudeba