摘要:问题:NSDate SDK4.1取得的时间全部为GMT了,怎么改成本地时间NSDateSDK4.1取得的时间全部为GMT了,怎么改成本地时间其它版本正常,取得的时间为本地时间谢谢~答案:NSTimeZone *zone = [NSTimeZone systemTimeZone];NSInteger interval = [zone secondsFromGMTForDate:date];NSDate *localeDate = [date addTimeInterval:interval];这样就转化为本地时间了,但是以前正常的版本也加了8小时,所以还是有问题。。。。
阅读全文
摘要:#define isRetina ([UIScreen instancesRespondToSelector:@selector(currentMode)] ? CGSizeEqualToSize(CGSizeMake(640,960), [[UIScreen mainScreen] currentMode].size) : NO)
阅读全文
摘要:在active.com的开发项目中,遇到一个动态显示detail page的问题。取的数据有的时候多有的时候少,而且还需要自动换行。计算行的高度,text的长度,大小等。EventAddresslabel=[[UILabelalloc]initWithFrame:CGRectMake(starttimelabel.frame.origin.x, starttimelabel.frame.origin.y+distance,270,20)];EventAddresslabel.backgroundColor=[UIColorclearColor];EventAddresslabel.textCo
阅读全文
摘要:UIButton *button= [[UIButton alloc] initWithFrame:CGRectMake(0,0,70,70)];button.buttonType = UIButtonTypeCustom;UIImage *buttonImage = [UIImage imageNamed:@"image.png"];UIImage *stretchableButtonImage = [buttonImage stretchableImageWithLeftCapWidth:12 topCapHeight:0];[button setBackgroundI
阅读全文
摘要:在使用UISearchBar时,将背景色设定为clearColor,或者将translucent设为YES,都不能使背景透明,经过一番研究,发现了一种超级简单和实用的方法:1[[searchbar.subviews objectAtIndex:0]removeFromSuperview];背景完全消除了,只剩下搜索框本身了。
阅读全文
摘要:1. 首先要明确的是,不使用pushViewController的默认动画,所以在调用这个函数时,要将animated设置为NO.2. 使用普通的来CATransition实现转换效果,代码如下: CATransition *animation = [CATransition animation]; [animation setDuration:0.3]; [animation setType: kCATransitionMoveIn]; [animation setSubtype: kCATransitionFromTop]; [animation setTimingFunction:[CA
阅读全文
摘要:自定义了一个UITableViewCell,但是在显示在TableView中时,第一个Cell左上角和右上角显示的时候,没有圆角,检查了一下代码,将Cell子类中设置frame的语句屏蔽掉就可以了:- (id)initWithStyle:(UITableViewCellStyle) style reuseIdentifier: (NSString *) reuseIdentifier{ if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) { //remove this line to keep firs
阅读全文
摘要:图片圆角 image round corner:m_mainImgView.layer.cornerRadius = 6;m_mainImgView.layer.masksToBounds = YES;自动适应,保持图片宽高比 aspect fit:m_mainImgView.contentMode = UIViewContentModeScaleAspectFit;见下图:Ori:round corner:Aspect Fit:
阅读全文
摘要:使UITableView最上面留出UINavigationBar空间的两种方法使UINavigationBar透明,TableView在其下面,可以扩大UITableView的视野.1) UIView *headerView = [[UIView alloc] initWithFrame: CGRectMake(0, 0, 320, 44)]; m_tableView.tableHeaderView = headerView;2) m_tableView.contentInset = UIEdgeInsetsMake(44, 0, 0, 0); m_tableView.scrollIndica
阅读全文
摘要:Bells And WhistlesThe iPhone has a set of nice transition animations which makes the experience using it very pleasant. But after a while one get so used of them that one stop noticing that they are even there. But this is not necessary a bad thing. Often I think thatreallygood things doesn’t show a
阅读全文
摘要:Search and highlight text in UIWebViewSeveral iPhone Apps (like my “iCab Mobile” or “NewsTap” Apps) provide a search feature which allows to search for text in the content that is currently displayed within a UIWebView. The found occurrences of the searched text are highlighted with a yellow backgro
阅读全文
摘要:WebKit on the iPhone (Part 1)If you develop an application which should display a web page or HTML file,you can use the WebKit framework, which is part of the MacOS and also of theiPhone OS.But while on the Mac, the WebKit framework provides almost 160 public headerfiles which define even more publi
阅读全文
摘要:iphone – Getting data from uiwebview textfield You can use [UIWebView stringByEvaluatingJavascriptFromString:] method and get the values by executing the javascript. Example: If your html is: Following code can get you the value of the text field: NSString* value = [webView stringByEvaluatingJavaSc.
阅读全文
摘要:ios和android都提供了有关webview和javascript通讯的功能,这就使开发者根据手机的系统展示适合手机的界面,是界面开发更加简单。 我的原型主要实现通过UIWebView展示本地的html、css、javascript文件,并且和ios互相通讯,用来展示数据。 下面是我实现的一个简单demo,界面效果如下: 点击连接调用ios中的提醒功能: 实现过程: 首先创建一个工程,ipad.web1,编译运行成功。 实现webview的代码: #import @interface ipad_web1ViewController : UIViewController { IBOutlet
阅读全文
摘要:获取所有html:NSString *lJs = @"document.documentElement.innerHTML"; 获取网页title:NSString *lJs2 = @"document.title"; UIWebView *lWebView = [self getCurrentWebView]; NSString *lHtml1 = [lWebView stringByEvaluatingJavaScriptFromString:lJs]; NSString *lHtml2 = [lWebView stringByEvaluatingJ
阅读全文
摘要:在info.plist文件里看看有没有“Application does not run in background”这一个key,如果没有,点最后一行,然后点这行右边的加号,你会看见最底下又变出来一行,在里面选择“Application does not run in background”,然后把钩打上
阅读全文
摘要:NSHTTPCookie *cookie;
NSHTTPCookieStorage *cookieJar = [NSHTTPCookieStorage sharedHTTPCookieStorage];
NSArray *cookieAry = [cookieJar cookiesForURL: [NSURL URLWithString: @"http://api.m.taobao.com"]];
for (cookie in cookieAry) {
[cookieJar deleteCookie: cookie];
}
阅读全文
摘要:下载下面的base64.zip然后皆压缩放到你的项目里面。然后我们自己写一个方法去调用即可,很简单,我自己封装了一个类去做,这样对我来说,库里的函数就比较透明了,当然也不是必须的。在我当前机器上可以使用,如果有问题请联系我。//.h文件,默认即可#import<Foundation/Foundation.h>@interface Utility : NSObject {}+(NSString*)encodeBase64:(NSString*)input;+(NSString*)decodeBase64:(NSString*)input;@end上面是头文件,下面是代码文件,我这样写
阅读全文
摘要:有一种思路叫寄生... 我相信是懒人推动了世界的发展,既然iphone有了自己的软件盘,我们什么还要自己实现其功能呢。 so,只要寄生在上面就行了。 感谢alan转载的文章给的灵感。 http://www.cocoachina.com/bbs/read.php?tid-3999.html 思路: 1.用静态方法找到应用程序当前view(window)中的UIKeyboard的view 2.在键盘的view上帖上自己的view,(精彩了,这个自己的view就是你自己键盘,任意发挥,什么类型键盘都可以做了) 3.根据需要调整系统键盘的大小以满足你想要的尺寸 4.给自己的键盘view上的button
阅读全文
摘要:今天出现这种错误,也许你也出现了,找了半天没有找到错误的根源。
呵呵,其实这个错误,真是太低级了,你一定#import "ClassName.m"
修改为 #import "ClassName.h" 就搞定了。
阅读全文