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
require 'rubygems' | |
require 'spork' | |
#uncomment the following line to use spork with the debugger | |
#require 'spork/ext/ruby-debug' | |
unless defined?(Rails) | |
require File.dirname(__FILE__) + "/../config/environment" | |
end | |
Spork.prefork do |
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
class Dog | |
def initialize(name) | |
@name = name | |
@cans = [] | |
end | |
def can(*args) | |
@cans = args | |
end |
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
#import "CoreText/CoreText.h" | |
#import <QuartzCore/QuartzCore.h> | |
enum GradientType { | |
LEFT2RIGHT = 1, | |
TOP2BOTTOM = 2, | |
RIGHT2LEFT = 3, | |
BOTTOM2TOP = 4 | |
}; |
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
class CleanRoom | |
def run(setups, &block) | |
setups.each do |setup| | |
instance_eval &setup | |
end | |
instance_eval &block | |
end | |
end |
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
-(void)webViewDidFinishLoad:(UIWebView *)webview { | |
CGSize size = [[[webview subviews]objectAtIndex:0] contentSize]; | |
[[[webview subviews]objectAtIndex:0] setScrollEnabled:NO]; | |
CGRect rc = webview.frame; | |
rc.size.height = size.height; | |
webview.frame = rc; | |
webview.hidden = NO; | |
UIView *cell = [[webview superview] superview]; | |
rc = cell.frame; |
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
<script language="javascript" type="text/javascript"> | |
document.onreadystatechange = function(){ | |
if(document.readyState=="complete") { | |
// alert(document.readyState); | |
window.location="/cmd/loadfinish"; | |
} | |
} | |
</script> |
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
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType { | |
if(navigationType == UIWebViewNavigationTypeOther ){ | |
NSString *ts = [request.URL absoluteString]; | |
if ([ts indexOfString:@"cmd/loadfinish"]>0){ | |
int scrollHeight = [[aWebView stringByEvaluatingJavaScriptFromString: @"document.body.scrollHeight"] intValue]; //此处为页面真实高度 | |
return NO; | |
} | |
} |
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
-(void) keyboardWillShow:(NSNotification*)notification { | |
NSDictionary* info =[notification userInfo]; | |
kbSize =[[info objectForKey:UIKeyboardFrameEndUserInfoKey]CGRectValue].size; | |
UIView *mainV = [self getMainView]; | |
CGPoint p =[self convertPoint:CGPointMake(0, self.frame.size.height) toView:mainV]; | |
if (p.y + kbSize.height > mainV.frame.size.height) { | |
[UIView beginAnimations:@"" context:nil]; | |
[UIView setAnimationCurve:0.3]; | |
CGRect rc = mainV.frame; |
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
- (void)textFieldDidBeginEditing:(UITextField *)textField { | |
[[NSNotificationCenter defaultCenter]addObserver:self selector:@selector(keyboardWillShow:) name:UIKeyboardWillShowNotification object:nil]; | |
UIView *mainV = [self getMainView]; | |
clickV = [[UIClickView alloc]initWithFrame:mainV.bounds]; | |
clickV.edit = input; | |
[mainV addSubview:clickV]; | |
[clickV release]; | |
[self becomeFirstResponder]; | |
} |
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
@interface UIClickView : UIView | |
@property (nonatomic,assign)UITextField* edit; | |
@end | |
@implementation UIClickView | |
- (UIView*)hitTest:(CGPoint)point withEvent:(UIEvent *)event { | |
CGPoint p = [self convertPoint:point toView:self.edit]; | |
if (p.x>0 && p.y>0) { | |
return nil; | |
} | |
return [super hitTest:point withEvent:event]; |