WebView displays in the wrong place in my ScreenSaverView

I wrote a screen saver that displays a web page. It works exactly how I want it on my primary display, but on the pre and secondary displays, the webview hangs on top of the screen.

Example (from preview):

Error screen saver http://img.skitch.com/20081212-nk5cqrgfds1funr1a3p72aw25q.preview.jpg
Uploaded via plasq Skitch !

My code is pretty simple. From the inside initWithFrame:isPreview:

, I have the following code:

webview = [[WebView alloc] initWithFrame:frame
                           frameName:@"main"
                           groupName:@"main"];
[self addSubview:webview];

      

Does anyone know what's going on?

If anyone wants to play with the project, the code is on github.

0


source to share


2 answers


I looked at your code and you are using the supervisor frame rectangle (WebSaverView) as the WebView frame. You should instead use its bounding box ( [self bounds]

). The bounding box represents the area "inside" the supervisor. As you saw, the two may not always have the same origin, which causes this problem. You shouldn't be adjusting the frame you passed in initWithFrame:

, as the source probably has a good reason not to be 0.0.



+1


source


I think the frame you are giving the WebView is in the wrong coordinates. Remember that the view frame is expressed in terms of the supervisor's coordinate system (bounds).



You should make the view the size of the supervisor -bounds

if I understood correctly what you want to do: it is usually a rectangle from (0,0) to (width, height).

+1


source







All Articles