The title says it all. I'm building an application with switches, sliders, and plots but no 2-dimensional display. Is there a way to delete the World display? Of course I can shrink it down, and I can set all the turtles to hidden?, but I can't find a way to get rid of it entirely. Thanks.
As Nicolas says, there is no official way to do this.
The workaround I would suggest is to set max-pxcor to 0, reducing the view's height to a minimum, then covering it with an opaque "note".
Click "Add", then select "Note", click in the Interface tab to create the note, then uncheck the "Transparent background" checkbox. Then drag and resize the note as needed.
There is officially no way to make the view disappear in NetLogo.
But (and I probably shouldn't be telling you this) there is a bug in NetLogo that you could take advantage of. If you run:
set-patch-size -1
...the view disappears!
If you save and re-load your model, however, it reappears. (This is because NetLogo makes sure that the view is some minimum size when loading a model.) You can get around that by using a startup procedure:
to startup
set-patch-size -1
end
But, be warned: you probably shouldn't do that. This is very much a hack. The bug will probably be fixed eventually, so you can't expect this to keep working. And it may very well cause other, unforeseeable problems.
The wisest thing to do is probably be to just move the view far out of the way, so that the user has to scroll a long way to see it. That would make the view "hidden" for most intents and purposes and wouldn't cause any trouble.
Related
When I draw any shape (Whether it's textured or not) it will flicker when I go to fullscreen and make the title bar show when I move the mouse to the top. It will turn lighter and then back for like a split second. I don't know if this happens with solid colors, but when I color the vertices and draw a gradient or apply textures, this happens. It's annoying, even though it's subtle. How can I fix it?
How to reproduce: Create a shape in Metal, either color the vertices differently to create a gradient, or apply a texture to it, and make the window fullscreen. Move the cursor to the top of the window. When the title bar shows up, the shape/texture will flash briefly. How can I fix that?
I am using macOS 1.15 Catalina.
This can be demonstrated even with the Xcode's example Metal game. Just go to fullscreen, show the title bar, and it will be unsmooth when you show and unshow the titlebar.
UPDATE: I have realized, that if I put the drawing code in viewDidLoad() instead of draw() this behavior will cease. How do I make it so that it's not buggy without having to only render ONE frame?
ANOTHER UPDATE: It does occur for solid colors.
This is a very difficult question, because I don't know what to try. This bug is also very hard to fix, because it only sometimes happens.
Example of the bug (Video)
Another example of the bug that displays the "white flicker" (Video)
Also this question was only half answered, because it turns out that I managed to fix the problem of the titlebar blocking the framerate, but there is still a problem with the white flash.
After watching your video, I understand what your problem is. In your case UI (Tittle Bar) is blocking the main thread, it's normal behavior because MTKView rendering occurs on the main application threads. You need to create a custom metal view and implement a render loop on a background thread.
Your best bet is to report this as a bug to Apple. I tried to research and there seems to be no results about this bug.
I assume you want a fix, but all I got is a workaround:
It doesn't seem to occur while the drawing code only runs once, in viewDidLoad. Maybe you could keep it there, and manually call the MetalView's draw method 60 times a second. I figured out how to get what I said to work. Leave the drawing code in draw, but make sure to set the preferred framerate to 0. Then manually redraw it 60 times a second. Because the draw method auto redrawing is buggy in this sense.
I am creating a map application, in which I am showing MKPolylineView(around 2000) and MKAnnotations with pin drop.
I want to make visible either set of MKPolylineViews or MKannotations at a time. I am managing it with 2 buttons, one button is to display set of MKPolylineViews and another for set of MKAnnotations. So I tried 2 methods to manage this scenario, which is following:
For MKAnnotations, I am removing it and adding it again.
In the case of MKPolylineViews, I tried 2 ways:
I tried to make all MKPolylineViews hidden to YES and NO to manage it visibility based on button click. In this case, when I make the MKPolylineViews visible from it's hidden state, not all the MKPolylineView are visible. I tried with alpha and hidden property. In both the cases, the result was same, not all the lines are visible. Is there any mechanism to make all the lines visible. Because the performance is good in this case.
Then I tried another way, in which I removed all the MKPolylineOverlays and add it again. This case, everything works well. But the main thread freeze the UI for some seconds. Remember I am adding around 2000 MKPolyLineView. How can I manage it.
Instead of removing the overlay, when I used the hidden and alpha property, the performance was good. But half of the lines are not visible, when I make it visible from it's hidden state. Around half of the overlays couldn't be visible.
Another help that I need is since I am using around 2000 MKOverlays, the app got free for a few seconds while zooming. I think in this case, the map is re rendering the overlay at each zoom level. Is there any way to handle it efficiently?
Can anyone help me the best way to handle this scenario.
Thanks and regards,
Sreelash
My app is behaving sluggishly. If i pop up a UIActionSheet, for example, instead of rolling in smoothly, it stutters in over about 5 frames. I know ideally you should have as little amount of views on screen as possible, but that's what I've got anyway.
Any suggestions for speeding it up?
EDIT:
On my view i have:
Custom navigation bar in place of the regular one. It's a UIImageView, using an image file. It has a quartzcore shadow. It contains 3 buttons. 2 of these buttons have 2 UIImages each, for normal and highlighted, generated from code when the view is shown. The other button uses an image file for normal and for highlighted.
An image file for a background lies under that. On top of the background is a UITableView. By default, it doesn't have any cells (the user adds them). We'll ignore the cell, since it's slugging regardless of their being there or not.
The header of the tableview contains some labels, and an editable uitextview. The size of the header changes as more lines are added to the textview. It also has a background image, which is transparent to allow you to see the view's background image behind it. It's loaded from a file, and a texture image on top of that is also loaded from a file.
The footer is simply a background image loaded from a file with the same texture on top.
Andrew, I'm afraid you haven't been quite specific enough to isolate the exact problem. However there are a couple of things I have picked out. Firstly, check your table view is set to be opaque. Also try to design your app so your table cells can be opaque. I'm assuming your design will allow this. You need to really know how to optimise view rendering performance if you want your table and it's cells to appear translucent over other content and it may be you would need to develop your own custom specialised alternative to UITableView if that is something you really need to know (can be done but quite advanced stuff).
Also you mention using Quartz shadow. You should be able to use UIKit for drawing shadows around images, unless you have some specialist requirement. Are you sure you need to use Quartz for what you want to do? Apologies if you already know this, but if you are fairly new to iOS development and have been looking up how to do shadows, you may have found the Quartz API's for doing that and assumed that is the solution, when (depending on what you need) you will probably be better off staying with UIKit. As a general rule of thumb, only use Quartz if you are sure you can't do what you want to do with just the UIKit API's.
Another thing to check. If you are using Quartz, then you are probably getting getting the graphics context for the UIImage view and drawing on the views context in drawRect: depending on how your view hierarchy is configured, and if you have your navigation bar view set to be transparent over the top of the UITableView, then your custom drawRect implementation may be getting called unnecessarily with every animation frame and this would be a big drain on performance.
Given the level of information you have given I'm having to guess a bit and can't give a precise answer. However for a definitive understanding of how to optimise UIView performance I recommend checking out this video (though you will need an Apple Developer account to be able to access it):
https://developer.apple.com/videos/wwdc/2011/
Session 121 – Understanding UIKit Rendering
Hope this helps. Paul.
I have an infinite scrollview in which I add images as the user scrolls. Those images have varying heights and I've been trying to come up with the best way of finding a clear space inside the current bounds of the view that would allow me to add the image view.
Is there anything built-in that would make my search more efficient?
The problem is I want the images to be sort of glued to one another with no blank space between them. Making the search through 320x480 pixels tends to be quite a CPU hog. Does anyone know an efficient method to do it?
Thanks!
It seems that you're scrolling this thing vertically (you mentioned varying image heights).
There's nothing built in to UIScrollView that will do this for you. You'll have to track your UIImageView subviews manually. You could simply maintain the max y coordinate occupied by you images as you add them.
You might consider using UITableView instead, and implementing a very customized tableView:heightForRowAtIndexPath: in your delegate. You would probably need to do something special with the actual cells as well, but it would seem to make your job a little easier.
Also, for what it's worth, you might find a way to avoid making your solution infinite. Be careful about your memory footprint! iOS will shut your app off if things get out of hand.
UPDATE
Ok, now I understand what you're going for. I had imagined that you were presenting photographs or something rectangular like that. If I were trying to cover a scroll view with UILeafs (wah wah) I would take a statistical approach. I would 'paint' leaves randomly along horizontal/vertical strips as the user scrolls. Perhaps that's what you're doing already? Whatever you're doing I think it looks good.
Now I guess that the reason you're asking is to prevent the little random white spots that show through - is that right? If I may suggest a different solution: try to color the background of your scroll view to something earthy that looks good if it shows through here and there.
Also, it occurred to me that you could use a larger template image -- something that already has a nice distribution of leaves -- with transparency all along the outside outline of the leaves but nowhere else. Then you could tile these, but with overlap, so that the alpha just shows through to the leaves below. You could have a number of these images so that it doesn't look obvious. This would take away all of the uncertainty and make your retiling very efficient.
Also, consider learning about CoreAnimation (CALayer in particular) and CoreGraphics/Quartz 2D ). Proper use of these libraries will probably yield great improvements in rendering speed.
UPDATE 2:
If your images are all 150px wide, then split your scrollview into columns and add/remove based on those (as discussed in chat).
Good luck!
I would like to have my user scroll inside a CPXYGraph. I have a CPXYGraph as part of a CPHostingLayer, like in the tutorials. I enabled allowsUserInteraction, which is cool and allows scrolling. But I don't want to allow my user to scroll to 'infinity', which it seems like it allows-you can keep dragging further and further away from where the data is on a plot.
How do I constrain this so that the user can only scroll within a certain bounds?
I also enabled masksToBorder, and set the outerBorderPath and innerBorderPath to something arbitarily small, but I saw no changes, so I am not sure how those are supposed to work.
I could not set maskingPath and subLayerMaskingPath because they seem to be read only(no setters), though i feel like these two properties might be what I am looking for.
Anyone has run into this situation? Would be glad if someone could shed some light. Thanks!
The masking properties only affect the drawing. You need to use the globalXRange and globalYRange properties of your plot space. These define the maximum range that can be scrolled into view. See the example in CPTestApp.