In the XIB file corresponding to the view of a viewcontroller, with Autolayout turned on, I drag out a button and place it at an arbitrary location so that Interface Builder automatically generates vertical and horizontal spacing constraints between the button and its superview (i.e. the VC's view). In the view controller .m file, I create IBOutlets to these two constraints and in the viewDidLoad method, remove them from the VC's view [self.view removeConstraint:self.vConstraint] etc. (And no, I didn't forget to make the outlet connections)
Upon running the app, I expect that Xcode (version 4.5.1, if that matters) would complain about the layout being ambigious but surprisingly (to me), it doesn't.
So how is the button's frame's origin being calculated? The button does appear in its superview at the position it was dropped at in Interface Builder, but I'd like to know precisely what Autolayout is doing in this situation (preferably with a reference to the official documentation).
It seems difficult to find exact documentation or other references on this. A look at Florian Kugler's page on the Advanced Auto Layout Toolbox had some great information. As I thought this was an interesting question I did some digging around.
I set up a test project with a UIButton myButton setup in the Xib and a couple of space constraint outlets:
#property (weak, nonatomic) IBOutlet NSLayoutConstraint *hSpaceConstraint;
#property (weak, nonatomic) IBOutlet NSLayoutConstraint *vSpaceConstraint;
As you stated, removing these constraints in viewDidLoad had no effect. Even outputting [self.myButton hasAmbiguousLayout] immediately after removing the constraints in viewDidLoad shows false.
However, by viewDidAppear, things have changed. myButton is correctly flagged as ambiguous by both hasAmbiguousLayout and also by doing an Auto Layout trace in lldb:
(lldb) po [[UIWindow keyWindow] _autolayoutTrace]
*<UIWindow:0x8a94fe0> - AMBIGUOUS LAYOUT
| *<UIView:0x8c55340>
| | *<UIRoundedRectButton:0x8c54100> - AMBIGUOUS LAYOUT
| | | <UIImageView:0x8c54580>
| | | <UIButtonLabel:0x8c595a0>
(lldb)
At this stage, we can also exercise the ambiguity:
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[self.myButton exerciseAmbiguityInLayout];
}
Without exercising:
Exercising:
There's nothing on the console either. That surprised me as I'm used to Auto Layout splurging a ton of constraint exceptions at the first sign of trouble.
Investigating that, a quick search here on SO revealed that
"ambiguity can be temporarily tolerated (unlike unsatisfiability,
which immediately raises an exception)"
So that explains the clear console, at least for now.
To conclude then, I believe that by the time viewDidLoad executes, a measure, layout, and display pass has already occurred. Removing the constraints then renders the view ambiguous. Auto Layout then does the common sense thing on a view that it no longer knows how to layout; nothing. The view remains in situ.
Related
I updated my nVidia drivers and suddenly started getting the following validation error:
VUID-vkCmdDrawIndexed-blendEnable-04727(ERROR / SPEC): msgNum:
-1979288290 - Validation Error: [ VUID-vkCmdDrawIndexed-blendEnable-04727 ] Object 0: handle =
0x5eb05e000000003b, type = VK_OBJECT_TYPE_PIPELINE; | MessageID =
0x8a06751e | vkCmdDrawIndexed: Image view's format features of the
color attachment (0) of the active subpass do not contain
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT bit, but active
pipeline's pAttachments[0].blendEnable is not VK_FALSE. The Vulkan
spec states: If rasterization is not disabled in the bound graphics
pipeline, then for each color attachment in the subpass, if the
corresponding image view's format features do not contain
VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT, then the blendEnable
member of the corresponding element of the pAttachments member of
pColorBlendState must be VK_FALSE
(https://vulkan.lunarg.com/doc/view/1.3.211.0/windows/1.3-extensions/vkspec.html#VUID-vkCmdDrawIndexed-blendEnable-04727)
Things still render correctly, but I'd like to fix the validation issue.
I am a bit confused as to how I set the VK_FORMAT_FEATURE_COLOR_ATTACHMENT_BLEND_BIT flag or if its part of the format vkGetPhysicalDeviceSurfaceFormatsKHR returns.
If it's the former, how do i set it and if it's the latter, how do i draw to it with blending enabled and not get validation errors?
Thank you!
Format features are not something you set; they're limitations that the Vulkan implementation informs you that you must work within. In particular, format features are properties that restrict how you may use any image with a particular combination of format, tiling, and so forth.
Swapchain images are subject to the same limitations as user-created images. The specification details what the equivalent VkImageCreateInfo would be for a particular vkCreateSwapchainKHR call. So those are the parameters you will need to send to vkGetPhysicalDeviceFormatProperties to see if your implementation supports some particular use of the swapchain image.
Blending is such a use. Apparently, whatever format you used to use allowed blending under the old driver, but this changed. And your code never verified that it was allowed.
Well, I missed another validation error that gave me the clue to find the issue. I had to update the VkApplicationInfo apiVersion to VK_API_VERSION_1_3. Leaving the answer here in case it helps anyone else.
I am working on a wpf-project that used a ScrollViewer to show a range of items.
In order to create a more advanced look and feel for the application, I replaced the Scrollviewer with a Carousel-control.
The code for the Carousel-control I downloaded from here:
https://www.codeproject.com/Articles/181835/WPF-Carousel-Control
Conceptually, the carousel control (as part of my wider application) consists of a large black box (which one does not need to touch) plus just a few lines of code for plugging in the carousel control. The black box is the Carousel project, highlighted in the following screenshot:
In order to plug the carousel-control in the application, just a couple of lines had to be commented out and a couple of other lines had to be added. The comments in the following two screenshots mark off the lines of code that had to be commented out and the lines of code that had to be added (in order for the scrollviewer-control to be replaced by the carousel-control):
... and (at the end of the file):
Furthermore, at the beginning of the xaml-file that contains the carousel, the following line was included:
xmlns:Carousel="clr-namespace:Carousel;assembly=Carousel"
as can be seen in the following screenshot:
As you can see, at the moment, the code for the scrollviewer is commented out. Hence, the application is using the Carousel at the moment.
This carousel works fine. However, the error list shows a bunch of errors, mostly of the following type:
the name "XYZ" does not exist in the namespace "bla".
The following screenshot shows some of the error messages:
As already mentioned, the carousel-control works despite those error messages. However, I still need to get rid of the error messages before leaving this project.
Regarding the error messages, the following points might be of interest:
No error messages are shown, when the scrollviewer-control is used.
As you can see from screenshot 5, most error messages refer to line 1 of the file CarouselControl.xaml. This file is located inside the "black box":
The beginning of file CarouselControl.xaml contains the following lines of code:
As you can see from screenshot 5, most of the error messages say that some name or property does not exist in namespace xyz, whereby namespace xyz is one of the namespaces listed at the beginning of file CarouselControl.xaml (see screenshot 7).
********************************UPDATE*****************************************
(Right-click on) Solution -> Properties -> Configuration Properties, I noticed that it was apparently not possible to change the configuration of the Carousel-project to anything other than platform x86:
No matter which platform I selected (from the drop down menu at the top of the screenshot), the platform for the Carousel-project stubbornly remained at value "x86".
Might this have something to do with the error messages?
I'm not sure how useful this may be, but I believe I have found the code that was the source of my problem:
var variables = values[0] as ObservableCollection<variable>;
var identifier = values[1] as string;
var variable = variables.SingleOrDefault(x => x.identifier == identifier);
if (variable == null) return "";
This is code of my converter to access a variable in a collection and return its value as a string, it was used on a TextBox control.
Looking back over my branches, it seems that I made this change:
var variable = variables?.SingleOrDefault(x => x.identifier == identifier);
Resharper suggested adding a Null-conditional Operator at this point, which solved my issue. It would seem that the designer was returning errors due to the LINQ expression, since the collection at this point was uninitialized.
I would look through your code to see if you have a similar instance of uninitialized collections.
Stuck at a trivial problem in Grails 3.1.5: Show the fields of a domain object, excluding one of them, including a transient property. Yes, this is my first Grails 3 project after many years with previous versions.
The generated show.gsp contains
<f:display bean="rfaPdffile"/>
This will include a field that may contain megabytes of XML. It should never be shown interactively. The display: false constraint is no longer in the docs, and seems to be silenty ignored.
Next I tried explicitly naming the fields:
<f:with bean="rfaPdffile">
<f:display property='fileName'/>
<f:display property='pageCount'/>
...
</f:with>
This version suprisingly displays the values without any markup whatsoever. Changing display to field,
<f:with bean="rfaPdffile">
<f:field property='fileName'/>
<f:field property='pageCount'/>
...
</f:with>
sort of works, but shows editable values. So does f:all.
In addition I tried adding other attributes to f:display: properties (like in f:table), except (like in f:all). I note in passing that those two attributes have different syntax for similar purposes.
In the Field plugin docs my use case is explicitly mentioned as a design goal. I must have missed something obvious.
My aim is to quickly throw together a prototype gui, postponing the details until later. Clues are greatly appreciated
If I understood you correctly, you want to have all bean properties included in the gsp but the one with the "megabytes of XML" should not be displayed to the user?
If that is the case you can do:
f:with bean="beanName"
f:field property="firstPropertyName"
f:field property="secondPropertyName"
And the one you don't wish to display:
g:hiddenField name="propertyName" value="${beanName.propertyName?}"
f:with
So list all the properties as f:field or f:display and put the one you don't wish to display in a g:hiddenField Grails tag
You can also try:
f:field property="propertyName"
widget-hidden="true"
but the Label is not hidden in this case.
Hope it helps
My own answer: "use the force, read the source". The f:display tag has two rather obvious bugs. I will submit a pull request as soon as I can.
Bugs aside, the documentation does not mention that the plugin may pick up the "scaffold" static property from the domain, if it has one. Its value should be a map. Its "exclude" key may define a list of property names (List of String) to be excluded. This probably works already for the "f:all" tag; bug correction is needed for the "f:display" tag.
My subjective impression is that the fields plugin is in a tight spot. It is intertwined with the Grails architecture, making it sensitive to changes in Grails internals. It is also required by the standard scaffolding plugin, making it very visible. Thus it needs constant attention from maintainers, a position not to be envied. Even now conventions for default constraints seem to have changed somewhere between Grails 3.0.9 and 3.1.7.
Performance of the fields plugin is sensitive to the total number of plugins in the app where it is used. It searches all plugins dynamically for templates.
For the wish list I would prefer stricter tag naming. The main tags should be verbs. There are two main actions, show and edit. For each action there are two main variants, single bean or multiple beans.
My answer is that at present (2 March 2017) there is no answer. I have searched the Net high and low. For the index (list) and create and edit views, the fields plugin works well enough. A certain field can be easily excluded from the create and edit views, relatively easily from the list view (by listing those that should show), and in no way I could find from the show view. This is such a common need that one would suspect it will be addressed soon. Also, easily showing derived values in the show view, like 'total' for an invoice. One can do that by adding an ordered list with a list item showing the value below the generated ordered list of values, but that is kind of a hack.
In some ways, the old way was easier. Yes, it generated long views, but they were generated and didn't have to be done by the programmer - just custom touches here and there.
I have declared an event in "Question" class as:
public event SectionAffected OnSectionAffected;
I have not used this event in the entire class.But I have used it in another class as:
Question.OnSectionAffected += new Question.SectionAffected(ResetDependentSection);
I am getting warning as:
The event 'QuestionManager.OnSectionAffected' is never used in Question class.
How to solve this warning?
A warning is just that... a warning. Having warnings is not necessarily a bad thing. However, if you really want to remove it, you can specify that in Visual Studio. If you open the relevant project's property page (by pressing ALT + Enter when the project is focused), turn to the Build tab. Click the RadioButton named Specific warnings and enter the specific error code(s) that you want to supress in a comma separated list. You can find out more from the How to: Suppress Compiler Warnings page on MSDN.
UPDATE >>>
I believe that you are looking for the numerical error code number... for this, you should look in the Output Window of Visual Studio. If you don't already use this window when writing WPF, then I would strongly advise you to do so. However, these codes are not always shown in this window.
As an alternative, you can find descriptions and error codes in the C# Compiler Errors and Code Analysis for Managed Code Warnings pages on MSDN.
UPDATE 2 >>>
After doing a quick search online (which is really what you should have done), I found this page which seems about right: Compiler Warning (level 3) CS0219
I have a clutter texture as my background . I need to put some clutter actors over it. is it possible to do it . Since i get the following error:
"invalid cast from `ClutterTexture' to `ClutterContainer' "
Can any one help me ?
ClutterTexture is not a container, i.e. it cannot contain other actors.
ClutterBox and ClutterGroup are containers available in Clutter; ClutterBox allows using different layout managers - like ClutterBinLayout:
http://developer.gnome.org/clutter/stable/ClutterBinLayout.html
or ClutterFixedLayout:
http://developer.gnome.org/clutter/stable/ClutterFixedLayout.html
you can also use ClutterGroup, and use constraints to maintain a layout:
http://developer.gnome.org/clutter/stable/ClutterConstraint.html
It has been a while since I have used clutter but I will try to provide some insights. As the error says you cannot cast ClutterTexture to ClutterContainer. You can add actors only to container actors. If you want to setup background one of the options could be stacking of actors. You can stack other actors on top of the actor with background texture using layout managers. This link provides some details which I think can be useful in your case.
Hope this helps!