I have a webview that shows some animated boxes, but it slows down and lags horribly when I put a drop shadow in the view. Without the shadow, the webview contents animate smoothly.
I achieved a similar effect as safari/chrome when you do a elastic scroll with the touchpad. Looks nice! But doesnt run as smooth as in my inspirations.
Here is the snippet of the shadow setting:
NSShadow *dropShadow = [[NSShadow alloc] init];
[dropShadow setShadowColor:[NSColor blackColor]];
[dropShadow setShadowOffset:NSMakeSize(0, 0)];
[dropShadow setShadowBlurRadius:5.0];
[webview setWantsLayer: YES];
[webview setShadow: dropShadow];
[dropShadow release];
--
My question is: How can I work around this problem?
You should not call setWantsLayer:YES on a WebView. Layer-backed web views are unsupported. This was actually pointed out in the 10.5 release notes and has not changed, unfortunately. You'll need to come up with an alternative solution.
Related
When I transition from MainMenuScene.m to SceneLvl1.m, the transition works perfectly fine. But when transitioning back from SceneLvl1.m to MainMenuScene.m, all the sprites are distorted. They're stretched out to almost 3x their original width! Here's my transitioning code:
// Main Menu initialization.
MainMenuScene *mainMenu = [[MainMenuScene alloc] init];
// Move to the main menu.
[self.scene.view presentScene:mainMenu
transition:[SKTransition fadeWithColor:[SKColor blackColor]
duration:3.0]];
So, what could I be doing wrong, here?
This might sound a stupid question, but are you calling simply init in it?
Any scene initialization should use initWithSize, right?
Try replacing with
MainMenuScene *mainMenu = [[MainMenuScene alloc] initWithSize:self.view.frame.size];
Im using:
#define colorApp [UIColor colorWithRed:254/256.f green:64/256.f blue:89/256.f alpha:1.0]
Inside the customSearchView init:
[self setBackgroundColor:colorApp];
searchBar = [[UISearchBar alloc] initWithFrame:frame];
searchBar.barTintColor = colorApp;
[self addSubview:searchBar];
Getting the next result:
I need the searchBarTint color to be the same as the navigation. Translucent doesn't seem to make the work.
I came up with the fix soon after I posted the question.
In case anyone ever faces this problem I used
[self.searchDisplayController.searchBar setBackgroundImage:[UIImage imageNamed:#"pinkBar.png"]
forBarPosition:0
barMetrics:UIBarMetricsDefault];
It seems backgroundColor and barTintColor aren't taking colors same way as the navigation for a UISearchDisplayController since iOS 7. But adding an image with that color just resolves that.
I know it's just a quick fix but it helped me and could help others as it is a minor visual issue.
I tried to use setNeedsDisplay, but that is very much up to the mercy of the system whether to refresh right the way. Currently I remove and add the subview every time, so the latest content is forced to show. The code works, however it lacks gracefulness.
[myView removeFromSuperview];
[myView release];
myView = [[MyView alloc] initWithFrame:CGRectMake(0.0, MY_VIEW_Y, 320.0, MY_VIEW_H)];
[self.view addSubview:myView];
//[self.myView setNeedsDisplay];
[self.view bringSubviewToFront: myView];
Your view should be getting redrawn at the next drawing cycle. Is this not happening or is this too slow for you? ... i.e.: how fast do you need it to redraw and what latency are you seeing between calling setNeedsDisplay and drawRect being called?
If you need more precise control of the drawing, you may need to use a view backed by CAEAGLLayer, in which case it runs from openGL and setNeedsDisplay has no effect.
I have an NSBox set up in my main view that accepts drag and drop. We store the URL into str. We then load the image and add it to the content view of NSBox.
imageView = [[NSImageView alloc] initWithFrame:CGRectMake(0, 0, 390, 150)];
NSURL *imageURL = [NSURL URLWithString:str];
NSImage *image = [[NSImage alloc] initByReferencingURL:imageURL];
[imageView setImage:image];
[self setContentView:imageView];
However, this doesn't do anything. The image is not displayed in the nsbox.
Another oddity. At first I was trying to add the NSImageView via interface builder, but the only image container they had was IKImageView... Is this odd? Isn't NSImageView more ubiquitous? I mainly develop on iOS, so I have the version from the ios developer site.
Any thoughts?
Edit: I should also add, when I was using IKImageView in IB, the image would show up.
Edit2: I've also tried just taking the initWithFrame out and replacing it with just init, no go.
The problem was that I was using initByReferencingURL to get the NSImage. This doesn't work for local files, so instead I used initByReferencingFile and everything worked out well!
I am using a CALayer to display a path via drawLayer:inContext delegate method, which resides in the view controller of the view that the layer belongs to. Each time the user moves their finger on the screen the path is updated and the layer is redrawn. However, the drawing doesn't keep up with the touches: there is always a slight lag in displaying the last two points of the path. It also flickers, but only while displaying the last two-three points again. If I just do the drawing in the view's drawRect, it works fine and the drawing is definitely fast enough.
Does anyone know why it behaves like this? I suspect it is something to do with the layer buffering, but I couldn't find any documentation about it.
[UIView new] is simply shorthand for [[UIView alloc] init].
Give the following before setNeedsDisplay method::
[CATransaction begin];
[CATransaction setValue:[NSNumber numberWithFloat:someDelay] forKey:kCATransactionAnimationDuration];
[aLayer setNeedsDisplay];
[CATransaction commit];
You might have better luck using a layer hosting view.
Instead of using the drawLayer:inContext: method, setup the view you want and add a CALayer to it:
UIView *layerHosting = [[UIView alloc] initWithFrame:frame];
[layerHosting setLayer:[[CALayer new] autorelease]];
Hope that helps!