Autolayout Ambiguous WTF! UIViewController's ___LayoutGuide properties ambiguous - uiviewcontroller

When I pause my app in the debugger and
po [[[[UIApplication sharedApplication] delegate] window] _autolayoutTrace]
The recursive description that comes out the other end shows the following:
*<UIWindow:0xc03d900> - AMBIGUOUS LAYOUT
| *<UILayoutContainerView:0xc070ac0>
<<SNIP>>
| | | | | | | | *<_UILayoutGuide:0x134b6240> - AMBIGUOUS LAYOUT
| | | | | | | | *<_UILayoutGuide:0x1348a2f0> - AMBIGUOUS LAYOUT
Okay, well my guess is those are UIViewController's topLayoutGuide and bottomLayoutGuide properties, but how and why are they ambiguous?
These print as ambiguous regardless of which of my view controller subclasses is front most. My content view controllers are being nested inside of UINavigationController installed inside of a UITabBarController. There's nothing surprising or unusual about the setup. UIViewController subclasses, UITableViewController subclasses - doesn't matter, guides still are ambiguous.

I filed a bug report about this a month ago (rdar://15402294) http://openradar.appspot.com/radar?id=5327306709008384
Apple only asked for a sample project afterwards and the issue is still open. You can file a duplicate bug report. The more bug reports they have, the quicker they fix the issue.
UPDATE: my bug report was closed as a duplicate of 10535951 (Open), so it's probably a known issue.

No one outside of Apple probably knows the answer to this question. The iOS system sets the view controller's top and bottom layout guides and _UILayoutGuide is private API. So we're only left with speculation.
In a sense, I see no reason why the term ambiguous would even be applicable to a layout guide. A layout guide is only used as a sort of proxy for a root view's chrome—a status and navigation bar at the top, or a tool bar at the bottom. Their only purpose is to help views position themselves along the vertical axis. Therefore, I see no reason why layout guides would even need any sort of horizontal alignment. And without horizontal alignment, a layout guide would be left permanently ambiguous.
In fact, if you log a top layout guide object, you get a rect with an origin of (0,0) and a width of 0:
<_UILayoutGuide: 0x89c7f60; frame = (0 0; 0 20);
It seems unfair that these hidden layout guides are being judged so harshly by the Auto Layout system. Their ambiguous state is an unsightly blemish on an otherwise beautiful _autolayoutTrace log.

Ambiguous layout generally means you don't have enough constraints to fully define the layout. My guess without seeing your storyboard or nib constraints is that you need some defining constraints for either your current view or the containing view your constraints attach to.
Can you post a screenshot of all your constraints for that view and the containing view?

Related

Grouped CSS Menu

I apologize if this question already exist but I'm not sure what is this called to even search for the correct resources.
I'm trying to create a tabbed header menu for different groups of people. In a sense, each group has their own custom menu which may still share pages. What I'm trying to do is to make the navigation intuitive depending who the site visitor is (what is relevant to the visitor).
eg.
| Student | Teacher | Parents |
| ----------------------------|
| Timetable, Homework, Activities ........|
| Student | Teacher | Parents |
|-------------| |-------------|
| Homework, Schedule .....................|
| Student | Teacher | Parents |
|---------------------------| |
| Timetable ..............................|
As you can see, the Student and Parent group menu both have "Timetable" page. The contents of the page is exactly the same (pointing to the same url). However, if a visitor accessed the Timetable page from the Student menu tab, when the page loads, the menu should show the navigation menu under the Student tab. Likewise if a visitor accessed the page via Parent tab.
Of course, I planned to add colours to the different tabs to further differentiate them, and even further dropdowns on certain items, but I'm stuck even at this preliminary stage.
Can anyone help enlighten me what is this feature called? Any name i could google with. I could read up resources and code it from then on. My searches so far are very disappointing and frustrating :(
Thanks much :)
one option i can suggest is
well first you will need to know who got in ...create log in window with logic you desire... log in with guest choice for parents
then you will have to create an asp file with option to check who is connected to show the right tab
(or you can create an choice bottom/input with JavaScript check)
http://www.w3schools.com/tags/tag_select.asp
look for something like
change Tab based on HTML Select value
on this site
it's not the full answer but it is beginning

MVC 5 Cascading Data

I am working on an MVC 5 razor page (using Entity Framework 6) that will display Vendor information. Each vendor can have multiple classes, and each class can have multiple subclasses. What I want to do is display the vendor information at the top, show the list of classes below that info, and then have a third section with a list of subclasses for the selected class. My question is what is the best way to do this?
Currently I am trying to do it with the main page getting passed a model of type vendor, and then within that page, displaying two partial views via #Html.Action("ActionName", "ControllerName", value). I can pass the class list partial view the ID of the vendor when the page loads without issue, the real problem is figuring out how to pass the selected ID of a class to the partial view for subclass. I've tried using hidden fields, but I'm not sure how to pass the html.Action the value of the hidden field.
This is my first MVC application, so any help is much appreciated.
First off, you are saying that you are using partial views with #Html.Action() helper - this is not for a partial view, but rather to produce a link to navigate to another page...That being said, I think I know what you want to do.
Second off, you need to post more code to show you made an attempt - stack overflow is not a source of free development consulting work. I think I know what you are trying to do, but even posting some sort of UI mockup might make a general discussion easier. That being said, I won't give you any code in the answer, just a general idea of how I would approach the problem.
To start, you should have a dedicated controller for Vendor, VendorClasses, and whatever the third subclass is (I'm going to assume its called VendorSubClass for the sake of example) since you chose the MVC pattern.
Next comes the part about displaying all of the information on a single page. The only place I could potentially see it making sense to show all of that info is on the views for VendorSubClass (however only VendorSubClass properties should be editable here) and even then, it might just make sense to have really informative breadcrumbs instead.
You would need to pass an object to the view that contained the VendorSubClass, its parent VendorClass, and its grandparent Vendor information. If you're using entity framework, this is a snap (but you didn't say you were so I'm making my explanation more generic). Then, you can reference partial views by using the helpers:
#Html.Partial('VendorPartial', Model.Vendor)
#Html.Partial('VendorClassPartial', Model.VendorClass)
as you can see above, I am not passing IDs - but rather the actual properties(objects) themselves which the partial views will use to render the details. This overview should get you started and give you some stuff to google.

How can I determine which items in a GridView that are visible in the current scroll window?

I have a GridView in my main app page and I want to do some background processing for the items that are currently in view for the user (high priority), and then of course do the other items too (low priority).
I can access the ScrollBar and the ScrollViewer, but none of them appear to tell me which of my items are in the current scroll window. I could try to hack this in, but it gets tricky because the number of row/columns change based on the size of the scroll region.
http://msdn.microsoft.com/en-us/library/windows/apps/br209745.aspx
http://msdn.microsoft.com/en-us/library/windows/apps/windows.ui.xaml.controls.scrollviewer.aspx
Any help much appreciated!
thanks
There are two general ways you can do this. The first is to get the GridViewItem's AutomationPeer, which actually has a direct method to call. Class information here. I've had problems getting this to actually be usable though. Luckily, there's a second answer. It will require some math to be done, but it's doable.
Get the item container, in this case a GridViewItem, using the GridView's ItemContainerGenerator.
Get the GridView's ScrollViewer. You can search for FindVisualChild<T> methods, there are plenty around.
Do MyGridViewItem.TransformToVisual(MyGridViewScrollViewer).TransformPoint(new Point(0, 0)); This will get you the top left corner of the item, relative to the entire scrollable panel (known as its Extent) of the ScrollViewer (this will be important later).
This will return to you a Point object.
Next, we'll need to find out the range of X values that are currently being displayed in the ScrollViewer.
Note: If you're using a Vertical scrolling ScrollViewer, use the Heights. Horizontal, use the Widths. Both, use both. I am going to do my example using the Horizontal/Width.
Take the HorizontalOffset. This is your current 'lower bound' for the current viewable region.
Take the HorizontalOffset plus the ViewportWidth. This is the upper bound of the current viewable region.
If your Point.X is greater than your lower bound and less than your upper bound, then the item is visible.
If you further need to find out if the whole item is visible, do
this same calculation for Point.X + GridViewItem.Width.
Hope this helps, and happy coding!
You can use VisualTreeHelper to scan the visual tree as Nate suggests, but this is usually not recommended at runtime, especially for tight loops (e.g. checking lots of GridViewItem objects) or complex visual trees. You could do a minor improvement and only calculate the position of these items once and then do a simplified check based on the ScrollViewer.ViewChanged event and offset values, but that still seems a bit too complicated.
If your GridView uses an ItemsPanel that supports virtualization (e.g. the default WrapGrid) - most of the items that are actually loaded into GridView items are actually visible or not far off the screen, so if you bind your GridView to a collection of view models using ItemsSource - you can figure out when these items are accessed by binding to their properties or handling Loaded/Unloaded events on the ItemTemplate and call back to the view models to know when they are getting accessed. That way you can start loading these items when they first start showing up on screen and leave the logic to determine whether they should be loaded to the list control virtualization implementation in the platform.

ListView add more items in Metro apps?

I have a metro application in which I have a Listview and service data contains above 100 items. Initially when am loading listview in my page it has to display only 8 items plus 1 more-related item and later if i click on a more-item it needs add another 9 items to my page and totally it has to show 17 items in my page and need to display more item also like that flow continues.What should I get to get my scenario.Can anyone help me.Below I tried to give u my scenario.
Thank you.
Take a look to this article: http://www.silverlightplayground.org/post/2012/06/10/Metro-Incrementally-load-GridView-and-ListView-with-ISupportIncrementalLoading.aspx.
There are a couple of solutions -- all depending on the work that you want to undertake. Also, I would suggest that you don't have a "More" button if you can help it -- it's not the best user interaction. Option 2 is going to give you the best experience.
Option 1
Use WinJS.Binding.List as your data source -- using this you can manipulate it like a JavaScript Array (e.g. push, pop etc). As you add & remove items from the list, the list view will react to those changes.
Full details are here.
Option 2
Create a VirtualDataSource derivation that is intimately aware of the ways in which you can request your data, and can offer up a consistent interface to the ListView. This enables your UI to be completely flexible to it's layout, and request enough data to satisfy the available space, while virtualizing the UI elements (better memory/performance), and the data (ensuring only the data needed by the user is requested.
Full worked example here.

Complex Itemrenderer ( List within a List), Struggling with scrolling behaviour ins second list

I'm struggling for a while with a scrolling problem now.
I'm developing a flex application with some complex views. On of the views is like a word document view. It pulls data from the database and represents requirement specification. You can also edit the data within this "word" view. It should basically work like microsoft word. That view works fine but I have one issue with it: Scrolling!
To realize that view I have created a complex ItemRendererClass that contains another complex ItemRenderClass. Imagine it like that>
-List of chapters (itemrenderer)
- Chapternumber + ChapterTitle
- ChapterText
- Chapterpicture
- List of data (itemrenderer)
- Requirementnumber
- RequirmeentText
- Pictures
- lots and lots of attributes
-...
All in all I'm really happy how the "word" view&editor works but if I'm scrolling down and I'm over the second lists which represents the list of requirements I can't scroll anymore, when the mouse is out of the list item I can scroll again. What I have done is I use virtual layout on both lists for performance reasons and the second lists height is a 100%, so the second scroller never appears. I have tried to disable the second scroller of the second lists with "this.scroller.setStyle('verticalScrollPolicy', 'off')". But nothing happens. What i want is a normal scrolling behaviour, means that it shouldn't matter where in the "wordview" the mouse is I want to scroll like it is one list and not 2 lists.
Ok, solved it. Was really easy actually. I just created a skin for the second list where i deleted the scroller component. In addition to that i had to sign the scroller from the second list to the parent List. Works like a charm so far