摘要:【问题现象】导航栏推进到某个ViewController,该ViewController的view的顶部控件被导航栏遮盖。需要对导航栏设置,使ViewController的View坐标自动进行Y偏移,如下:- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; UIViewC.
阅读全文
摘要:在文件xxxViewController.m中,// 添加前进按钮UIBarButtonItem *rightButton = [[UIBarButtonItem alloc] initWithTitle:@"Forward2" style:UIBarButtonItemStylePlain target:self action:@selector(forwardButtonPressed:)];self.navigationItem.rightBarButtonItem = rightButton; // 隐藏返回按钮UIBarButtonItem *leftButton
阅读全文
摘要:移除子视图两种方法方法1:for (int loop = 0; loop < [subViews count]; loop++){ UIView *subView = [subViews objectAtIndex:loop]; [subView removeFromSuperview];}方法2:NSArray *subViews = [subView subviews];if([subViews count] != 0){ [subViews makeObjectsPerformSelector:@selector(removeFromSuperview)];}
阅读全文
摘要:NSDateFormatter *format = [[NSDateFormatter alloc] init];[format setDateFormat:@"yyyy-mm-dd hh:mm:ss"];NSString *strDate = [format stringFromDate:[NSDate date]];DLog(@"%@", strDate);其中DLog定义#ifdef DEBUG #define DLog(fmt, ...) NSLog((@"%s [Line %d] " fmt), __PRETTY_FUNCT
阅读全文
摘要:【问题现象】创建自定义storyboard,添加ViewController之后通过instantiateViewControllerWithIdentifier方法创建ViewController异常。【问题分析】原始代码:- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{ // Override point for customization after application launch. self.window = [
阅读全文
摘要:使用UIWebView显示html,提示:err is Error Domain=WebKitErrorDomain Code=101 “The operation couldn’t be completed. (WebKitErrorDomain error 101.)”NSString *path = [[NSBundle mainBundle] pathForResource:@"vhugo" ofType:@"epub"];NSURL *url = [NSURL URLWithString:[path stringByAddingPercentE
阅读全文
摘要:- (void)drawRect:(CGRect)rect{ [self showPage:m_currentPageIndex];}- (void)showPage:(int)pageIndex{ CGContextRef cntxRef = UIGraphicsGetCurrentContext(); CGPDFPageRef page = CGPDFDocumentGetPage (m_docRef, pageIndex);// 2 // Quartz画图得坐标系统是以左下角为开始点,但iphone视图是以左上角为开始点 CGContextTranslateCTM(cntxRef, 0.
阅读全文
摘要:当使用NSLog打印时,不论是Debug模式还是Release模式,均会打印出来,并且无法找到是哪个类哪个方法,如下方式可参考解决这两个问题。#ifdefDEBUG#defineDLog(fmt,...)NSLog((@"%s[Line%d]"fmt),__PRETTY_FUNCTION__,__LINE__,##__VA_ARGS__);#else#defineDLog(fmt,...)#endif测试,在CViewController.m文件中代码:DLog(@"load %d", 3);打印结果:2014-01-0809:25:11.589Prot
阅读全文