Created
April 3, 2013 00:32
-
-
Save mikecsh/5297483 to your computer and use it in GitHub Desktop.
UIWebView Layout Issue
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* AppController.j | |
* WebViewTest | |
* | |
* Created by You on April 3, 2013. | |
* Copyright 2013, Your Company All rights reserved. | |
*/ | |
@import <Foundation/Foundation.j> | |
@import <AppKit/AppKit.j> | |
@implementation AppController : CPObject | |
{ | |
} | |
- (void)applicationDidFinishLaunching:(CPNotification)aNotification | |
{ | |
var theWindow = [[CPWindow alloc] initWithContentRect:CGRectMakeZero() styleMask:CPBorderlessBridgeWindowMask], | |
contentView = [theWindow contentView]; | |
// Set a BLUE background color so we can see where the contentView is being drawn | |
[contentView setBackgroundColor:[CPColor blueColor]]; | |
// Create a CPWebView with and set the content to a basic HTML doc with RED background | |
var webView = [[CPWebView alloc] initWithFrame:[contentView bounds]]; | |
[webView loadHTMLString:@"<html><head></head><body style='background:#f00'></body></html>"]; | |
[webView reload:self]; | |
[webView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; | |
// For comparison, create a CPView with a GREEN background | |
var plainView = [[CPView alloc] initWithFrame:[contentView bounds]]; | |
[plainView setBackgroundColor:[CPColor greenColor]]; | |
[plainView setAutoresizingMask:CPViewWidthSizable | CPViewHeightSizable]; | |
// Swap these to see how the CPWebView is improperly sized after having been "animated" and compare with the CPView | |
var viewUnderTest = webView; | |
// var viewUnderTest = plainView; | |
// Add the relevant view, and go | |
[contentView addSubview:viewUnderTest]; | |
[theWindow orderFront:self]; | |
// ---------------------------------------------------------------------------------------------------------------- | |
// Change the frame of the webview a few times to simulate a CPViewAnimation/LPViewAnimation/CPAnimation | |
window.setTimeout(function() | |
{ | |
console.log("1"); | |
[viewUnderTest setFrameOrigin:CGPointMake(10,10)]; | |
window.setTimeout(function() | |
{ | |
console.log("2"); | |
[viewUnderTest setFrameOrigin:CGPointMake(30,30)]; | |
window.setTimeout(function() | |
{ | |
console.log("3"); | |
[viewUnderTest setFrameOrigin:CGPointMake(0,0)]; // Should reset the frame to the original state | |
}, 1000); | |
}, 1000); | |
}, 1000); | |
} | |
@end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment