i set all constraints there is no probmem. But when i re-open the project all widths and heights values changes to 1000. There is only one view has problem. I deleted it then created again but still has same problem. How can i solve this?
Apparently this is a bug in Xcode 8.
Related Question: xcode-8-storyboard-warnings-for-navigation-bar-width
A possible solution presented in that related question is to change the Simulated Metrics size from Fixed to Freeform.
Also, here some open threads about common problems:
https://forums.developer.apple.com/thread/62929
https://forums.developer.apple.com/thread/63108
https://forums.developer.apple.com/thread/63144
https://forums.developer.apple.com/thread/61797
https://forums.developer.apple.com/thread/63029
https://forums.developer.apple.com/thread/63068
https://forums.developer.apple.com/thread/63067
https://forums.developer.apple.com/thread/63067
https://forums.developer.apple.com/thread/62821
https://forums.developer.apple.com/thread/62882
https://forums.developer.apple.com/thread/62321
Related
when I add constraints in Xcode add new constraints, all my 0 and negative 0 turns into standard and it gives some strange output when I set those constraints. How can I fix this?
Is this any new feature of Xcode or issue I don't know?
This is an issue from Xcode and they will resolve it in the next update. Beta version of this update is available on the Apple's website
They have fixed a bug that prevented entering a 0 constant in the constraint popup editors. (54076090)
I'm a little confused when seeing the new interface builder's size class options in Xcode 8 beta. I used to build my apps' UI by first design them in "Any" size class and then do some custom adjustments in the other ones. Is the workflow supposed to be changed in this new version of Xcode?
The UI to select the size classes has changed in xcode 8. Now it is as follows:
Any constraints that you add without selecting Vary for Traits options will be considered as for all the size classes( Any Any previously)
To add a constraint to a specific size class add it by selecting:
The device at the bottom and by selecting Vary for Traits
options of that size class.
When you are adding constraints to a specific size class the bar
turns blue as below
The way to do this has changed slightly in the new version of Xcode. It should build for "any-any" automatically. Have a look at this WWDC video that I think explains it in detail. There is also a part 2, so watch that if you need to.
https://developer.apple.com/videos/play/wwdc2016/222/
Hope I could help,
Zack
To convert from the old Any by Any to the new Trait layout, go through each of your View Controllers and update all frames.
Yesterday, after not working on this project for some time, I booted up my mac again to continue this iOS project. Unfortunately, all of the sudden, after making a view fixed after making it freeform, Xcode gave me a "internal error. Please file a bug report and include /var/.........". I cleaned the project, but now every view appears to be empty, while there are objects in it. See the screenshot below.
Afterwards, I have updated to Xcode 7.2 where the problem still persists within this project. Other projects work correctly.
Better yet, whenever I place a new object, for example the picker view, it shows perfectly.
Thanks for taking the time to answer my problem
Regards,
Riekelt
Try this , I have solved same problem by this way.....
Storyboard -> Attribute inspector -> simulator size -> Fixed
Hope you would have fixed it already. I had also faced the same problem and solved it with following fix.
Changing size classes back and forth. Storyboard -> File inspector -> Interface Builder Document -> Use Size Classes(reverting the size class in storyboard to the size class which we designed our views originally).
I am new to IOS development. I am developing an app for IOS 8 devices. I used storyboard for my design yesterday my storyboard showing all UI design but today morning it show blank UIViewController no UI element vision please see in screen shot and very strange thing is that when i run my app all ui element visible in my device. I google but dont find any solution please help me out. Thank you in advance.
It looks to me like you are using size class and you went into a particular size class and added these views. Now you are back in Any size class, so the views are not there (that is why they are greyed out in the document outline at the left). They are available only for that particular size class. If you switch back to it again, whatever it was, you will see them again. Basically, you have created conditional views - the condition being that they are present only when that particular size class situation is the case.
In other words, if you want your layout to apply in the general case, you want to start by creating and editing it under Any size classes. Only then do you switch to a particular size class and modify the layout for that particular size class.
when i run my app all ui element visible in my device
Yes, because on your device the particular size class situation matches the size class you were editing when you added those views. So there they are. That seems to me to prove my guess is right.
I have the same issue while copy a ViewController to another storyboard.
Fixed by following steps:
1: Select the viewController
2: Click on 5th Tab
3: Set the simulated size to Fixed.
Select install:
Since all components [like label,textfield,buttons] are in disable mode, one select Installed check mark its will be enable again adjust constrain accordingly.
The size must be the same, in all xcode storyboard
In my case, it was due to me setting alpha to 0.0 and forgetting it.
I opened an existing iOS project with Xcode6 beta6, and Xcode lists the following warning for both Storyboard and Xib files:
Automatic Preferred Max Layout Width is not available on iOS versions
prior to 8.0
I tried addressing the warning by setting the width as explicit like below:
Yet this didn't resolve the warnings. How can they be removed?
Update 3:
This warning can also be triggered by labels that have numberOfLines set to anything but 1 if your deployment target is set to 7.1. This is completely reproducible with new single-view project.
Steps to Reproduce:
Create a new single-view, objective-c project
Set the Deployment Target to 7.1
Open the project's storyboard
Drop a label onto the provided view controller
Set the numberOfLines for that label to 2.
Compile
I've filed the following radar:
rdar://problem/18700567
Update 2:
Unfortunately, this is a thing again in the release version of Xcode 6. Note that you can, for the most part, manually edit your storyboard/xib to fix the problem. Per Charles A. in the comments below:
It's worth mentioning that you can pretty easily accidentally
introduce this warning, and the warning itself doesn't help in finding
the label that is the culprit. This is unfortunate in a complex
storyboard. You can open the storyboard as a source file and search
with the regex <label(?!.*preferredMaxLayoutWidth) to find labels that
omit a preferredMaxLayoutWidth attribute/value. If you add in
preferredMaxLayoutWidth="0" on such lines, it is the same as marking
explicit and setting the value 0.
Update 1:
This bug has now been fixed in Xcode 6 GM.
Original Answer
This is a bug in Xcode6-Beta6 and XCode6-Beta7 and can be safely ignored for now.
An Apple engineer in the Apple Developer forums had this to say about the bug:
Preferred max layout width is an auto layout property on UILabel that
allows it to automatically grow vertically to fit its content.
Versions of Xcode prior to 6.0 would set preferredMaxLayoutWidth for
multiline labels to the current bounds size at design time. You would
need to manually update preferredMaxLayoutWidth at runtime if your
horizontal layout changed.
iOS 8 added support for automatically computing
preferredMaxLayoutWidth at runtime, which makes creating multiline
labels even easier. This setting is not backwards compatible with iOS
7. To support both iOS 7 and iOS 8, Xcode 6 allows you to pick either "Automatic" or "Explicit" for preferredMaxLayoutWidth in the size
inspector. You should:
Pick "Automatic" if targeting iOS 8 for the best experience. Pick
"Explicit" if targeting < iOS 8. You can then enter the value of
preferredMaxLayoutWidth you would like set. Enabling "Explicit"
defaults to the current bounds size at the time you checked the box.
The warning will appear if (1) you're using auto layout, (2)
"Automatic" is set for a multiline label [you can check this in the
size inspector for the label], and (3) your deployment target < iOS 8.
It seems the bug is that this warning appears for non-autolayout
documents. If you are seeing this warning and not using auto layout
you can ignore the warning.
Alternately, you can work around the issue by using the file inspector on the storyboard or xib in question and change "Builds for" to "Builds for iOS 8.0 and Later"
To Find the problem label(s) in a large storyboard, follow my steps below.
In xCode's Issue Navigator right click on the error and select "Reveal In Log". (Note: #Sam suggests below, look in xCode's report navigator. Also #Rivera notes in the comments that "As of Xcode 6.1.1, clicking on the warning will automatically open and highlight the conflicting label". I haven't tested this).
This will show the error with a code at the end of your storyboard file. Copy the value after .storyboard
Next, reveal your storyboard as source file.
Search. You should be able to tell what label it is from here quite easily by looking at the content.
Once you find the label the solution that worked for me was to set the "preferred width" to 0.
BTW, you can always quickly get the id of an interface item by selecting the item and looking under the identify inspector. Very handy.
You can fix this issue without opening the storyboard as a source.
This warning is triggered by UILabels if numberOfLines !=1 and deployment target is < 8.0
HOW TO FIND IT?
Go to Issue Navigator (CMD+8) and Select latest built with the warning
Locate the warning(s) (search for "Automatic Preferred Max Layout") and press expand button on the right
Find the Object ID of the UILabel
Open the Storyboard and SEARCH (CMD+f) for the object. It will SELECT AND HIGHLIGHT the UILabel
Set Preferred Width = 0 "Explicit" as others suggested
Solution it's quite simple
Just enable Builds for iOS 8 and Later
Now my Xcode version is 6.1. But I got this warning too. it annoys me a lot . after search again and again.I found the solution.
Reason:You must have set your UILabel Lines > 1 in your Storyboard.
Solution: set your UILabel Lines attribute to 1 in Storyboard. restart your Xcode. It works for me, hope it can help more people.
If you really need to show your words more than 1 line. you should do it in the code.
//the words will show in UILabel
NSString *testString = #"Today I wanna set the line to multiple lines. bla bla ...... Today I wanna set the line to multiple lines. bla bla ......"
[self.UserNameLabel setNumberOfLines:0];
self.UserNameLabel.lineBreakMode = NSLineBreakByWordWrapping;
UIFont *font = [UIFont systemFontOfSize:12];
//Here I set the Label max width to 200, height to 60
CGSize size = CGSizeMake(200, 60);
CGRect labelRect = [testString boundingRectWithSize:size options:NSStringDrawingUsesLineFragmentOrigin attributes:[NSDictionary dictionaryWithObject:font forKey:NSFontAttributeName] context:nil];
self.UserNameLabel.frame = CGRectMake(self.UserNameLabel.frame.origin.x, self.UserNameLabel.frame.origin.y, labelRect.size.width, labelRect.size.height);
self.UserNameLabel.text = testString;
To summarize, for me following the two instructions above to change any instances where numberOfLines = 0 to 1 or greater, and manually adding preferredMaxLayoutWidth="0" to each instance of a label inside the storyboard source fixed all of my warnings.
Since I don't have a 50 reputation Stackoverflow wont let me comment on the second best answer. Found another trick for finding the culprit label in the Storyboard.
So once you know the id of the label, open your storyboard in a seperate tab with view controllers displayed and just do command F and command V and will take you straight to that label :)
I got it working by selecting the original layout I had in the W / H selection. Storyboard is working as expected and the error is gone.
Be also sure that you are developing for iOS 8.0. Check that from the project's general settings.
This is where you should press.
I had this issue and was able to fix it by adding constraints to determine the max with for a label.
When dropping a multiline label in there is not constraint set to enforce the width inside the parent view. This is where the new PreferredMaxWidth comes into play. On iOS 7 and earlier you have to define the max width yourself. I simply added a 10px constraint to the left and right hand side of the label.
You can also add a <= width constraint which also fixes the issue.
So this is not actually a bug, you simply have to define the max width yourself. The explicit option mention in other answer will also work as you are setting this width value however you will have to modify this value if you want the max width to change based on the parent width (as you have explicitly set the width).
My above solution ensures the width is always maintained no matter how big the parent view is.
For some reason, even if changing the iOS Deployment Target to 8.0 or higher, the Xib files don't adopt that change and remain with the previous settings in the File inspector
Therefore, you should change it manually for each Xib
Once done, the warning will disappear :-)