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)drawRect:(CGRect)rect | |
{ | |
// Drawing code | |
CGContextRef currentContext = UIGraphicsGetCurrentContext(); | |
CGContextSetFillColorWithColor(currentContext, [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:0.35].CGColor); | |
CGContextAddRect(currentContext, CGRectMake(0, 1, self.frame.size.width, 1)); | |
CGContextFillPath(currentContext); | |
CGGradientRef glossGradient; |
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
- (NSString *)stringFromTimeInterval:(NSTimeInterval)interval | |
{ | |
NSInteger ti = (NSInteger)interval; | |
NSInteger seconds = ti % 60; | |
NSInteger minutes = (ti / 60) % 60; | |
NSInteger hours = (ti / 3600); | |
NSString *time = nil; | |
if (hours > 0) { | |
time = [NSString stringWithFormat:@"%02i:%02i:%02i", hours, minutes, seconds]; | |
} |
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
// | |
// Example of formatting the date string | |
// "Tue, 16 Dec 2008 11:45:13 +0000" | |
// to | |
// "16. December 2008" | |
// | |
NSString *feedDateString = @"Tue, 16 Dec 2008 11:45:13 +0000"; | |
// | |
// A formatter to create a date using the RFC2822 date of a RSS feed |
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 <CommonCrypto/CommonDigest.h> | |
+ (NSString*)md5HexDigest:(NSString*)input | |
{ | |
const char* str = [input UTF8String]; | |
unsigned char result[CC_MD5_DIGEST_LENGTH]; | |
CC_MD5(str, strlen(str), result); | |
NSMutableString *ret = [NSMutableString stringWithCapacity:CC_MD5_DIGEST_LENGTH*2]; | |
for(int i = 0; i<CC_MD5_DIGEST_LENGTH; i++) { |
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
UIAlertView *alerView = [[UIAlertView alloc] initWithTitle:<#Code#> | |
message:<#Code#> | |
delegate:<#Code#> | |
cancelButtonTitle:@"确定" | |
otherButtonTitles:<#Code#>]; | |
[alerView show]; | |
[alerView release]; |
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
#include <stdio.h> | |
#include <stdlib.h> | |
extern "C" { | |
#include "lua.h" | |
#include "lauxlib.h" | |
#include "lualib.h" | |
} | |
#pragma comment(lib, "liblua.lib") |
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)registerForKeyboardNotifications | |
{ | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillShow:) | |
name:UIKeyboardWillShowNotification object:nil]; | |
[[NSNotificationCenter defaultCenter] addObserver:self | |
selector:@selector(keyboardWillBeHidden:) | |
name:UIKeyboardWillHideNotification object:nil]; | |
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
// | |
// ARCMacros.h | |
// | |
// Created by John Blanco on 1/28/2011. | |
// Rapture In Venice releases all rights to this code. Feel free use and/or copy it openly and freely! | |
// | |
#if !defined(__clang__) || __clang_major__ < 3 | |
#ifndef __bridge | |
#define __bridge |
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 *)req navigationType:(UIWebViewNavigationType)navigationType | |
{ | |
NSMutableURLRequest *request = (NSMutableURLRequest *)req; | |
if ([request respondsToSelector:@selector(setValue:forHTTPHeaderField:)]) { | |
[request setValue:@"Mozilla/5.0 (iPhone; U; CPU iPhone OS 3_0 like Mac OS X; en-us) AppleWebKit/528.18 (KHTML, like Gecko) Version/4.0 Mobile/7A341 Safari/528.16" forHTTPHeaderField:@"User_Agent"]; | |
} | |
return YES; | |
} |
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)savedPhotoImage:(UIImage*)image didFinishSavingWithError:(NSError *)error contextInfo: (void *)contextInfo { | |
UIAlertView *alert = nil; | |
if (error == nil) { | |
alert = [[UIAlertView alloc] initWithTitle:@"提示" message:@"图片保存成功!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; | |
} | |
else { | |
NSLog(@"%@", [error localizedDescription]); | |
NSLog(@"info: %@", contextInfo); | |
alert = [[UIAlertView alloc] initWithTitle:@"错误" message:@"图片保存失败,请重试!" delegate:self cancelButtonTitle:@"确定" otherButtonTitles:nil]; |
OlderNewer