摘要: 1 //表格透明 2 // 3 [TableView setBackgroundColor:[UIColor grayColor]]; 4 5 //Cellu背景色设置 6 7 - (UITableViewCell *)tableView:(UITableView *)tableView1 cellForRowAtIndexPath:(NSIndexPath *)indexPath 8 9 {static NSString *SimpleTableIdentifier = @"SimpleTableIdentifier"; 10 11 UITableViewCell *ce 阅读全文
posted @ 2012-05-14 11:47 妙笔 阅读(429) 评论(0) 推荐(0) 编辑
摘要: 通常使用的Navigation Item中有backBarButtonItem/leftBarButtonItem/rightBarButtonItem三个按键,其中backBarButtonItem为只读,不能修改,其他两个都可以自由修改.不但可以防止button,还可以用自定义的view来填充,比方说想在导航栏右侧防止两个按钮,如图所示代码如下: 1 UIView *rightBarView = [[UIView alloc]initWithFrame:CGRectMake(618, 0, 150, 44)]; 2 3 UIButton *editBtn = [UIButton but.. 阅读全文
posted @ 2012-05-14 11:46 妙笔 阅读(1239) 评论(0) 推荐(0) 编辑
摘要: 导航栏的按钮,右边的按钮是可以自己随意添加的。但左边的返回按钮怎么定制?正确的答案是重载UINavigationController类的pushViewController:animated方法。 1 #import @interface MyNavigationController: UINavigationController 2 3 { 4 5 } 6 7 @end 8 9 #import "MyNavigationController.h" 10 11 @implementation MyNavigationController 12 13 -(void)popse 阅读全文
posted @ 2012-05-14 11:45 妙笔 阅读(1409) 评论(0) 推荐(0) 编辑
摘要: 1 //CustomNavigationBar.h 2 @interface UINavigationBar (UINavigationBarCategory) 3 UIImageView *backgroundView; 4 - (void)setBackgroundImage:(UIImage*)image; 5 - (void)insertSubview:(UIView *)view atIndex:(NSInteger)index; 6 @end 7 //CustomNavigationBar.m 8 @implementation UINavigationBar (UINaviga. 阅读全文
posted @ 2012-05-14 11:44 妙笔 阅读(362) 评论(0) 推荐(0) 编辑
摘要: 实现右边的书签按钮: 1 UIBarButtonItem *anotherButton = [[UIBarButtonItem alloc] 2 3 initWithBarButtonSystemItem:UIBarButtonSystemItemBookmarks target:self 4 5 action:@selector(methodtocall:) ]; 6 7 self.navigationItem.rightBarButtonItem = anotherButton; [anotherButton release]; 8 9 //由于本地视图会retain它,所... 阅读全文
posted @ 2012-05-14 11:36 妙笔 阅读(131) 评论(0) 推荐(0) 编辑
摘要: 第一种: 1 NSStringEncoding encoder = NSUTF8StringEncoding; 2 3 NSString *file = [NSString stringWithContentsOfFile:@"/Users/bjimac/Desktop/528.edl" usedEncoding:&encoder 4 5 error:nil]; 6 7 NSRange line; 8 9 line.location = 0;10 11 l... 阅读全文
posted @ 2012-05-14 11:35 妙笔 阅读(343) 评论(0) 推荐(0) 编辑
摘要: NSFileHandle *fileHandle = [NSFileHandle fileHandleForReadingAtPath:filePath];[fileHandle seekToFileOffset:1000];NSData *data = [fileHandle readDataOfLength:2000]; 阅读全文
posted @ 2012-05-14 11:34 妙笔 阅读(383) 评论(0) 推荐(0) 编辑
摘要: 在网上查了下资料,有两种方法:方法一,利用Quartz本身的绘图方法: 1 - (void) drawText:(NSString *)text x:(float)x y:(float)y { 2 3 CGContextRef context = UIGraphicsGetCurrentContext(); 4 5 CGContextSelectFont(context, "Arial", 20, kCGEncodingMacRoman); 6 7 CGContextSetTextDrawingMode(context, kCGTextFill); 8 9 CGAffine 阅读全文
posted @ 2012-05-14 11:29 妙笔 阅读(3073) 评论(0) 推荐(0) 编辑
摘要: loadView 和 viewDidLoad 是 iPhone 开发中肯定要用到的两个方法。 他们都可以用来在视图载入的时候初始化一些内容。 但是他们有什么区别呢? viewDidLoad 方法只有当 view 从 nib 文件初始化的时候才被调用。viewDidLoad 用于初始化,加载时用到。 loadView 方法在控制器的 view 为 nil 的时候被调用。 此方法用于以编程的方式创建 view 的时候用到。loadView 是使用代码生成视图的时候,当视图第一次载入的时候调用的方法。用于使用(写)代码来实现控件。用于使用代码生成控件的函数。如:1 - ( void ) loadVi 阅读全文
posted @ 2012-05-14 11:26 妙笔 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 32位 64位char 1 1int 4 大多数4,少数8long 4 8float 4 4double 8 8指针 4 8 阅读全文
posted @ 2012-05-14 11:26 妙笔 阅读(1724) 评论(0) 推荐(0) 编辑
摘要: 这么细节的东西想来大家都不在意,平时也不会去关系,但是在面试时却常常被提到,所以了解viewController的生命周期还是很有必要的。由init、loadView、viewDidLoad、viewDidUnload、dealloc的关系说起init方法在init方法中实例化必要的对象(遵从LazyLoad思想)?init方法中初始化ViewController本身loadView方法当view需要被展示而它却是nil时,viewController会调用该方法。不要直接调用该方法。如果手工维护views,必须重载重写该方法如果使用IB维护views,必须不能重载重写该方法loadView和 阅读全文
posted @ 2012-05-14 11:25 妙笔 阅读(121) 评论(0) 推荐(0) 编辑
摘要: viewDidAppear、viewWillAppear in UINavigationController not be calledWhen you push or pop a view controller on/off a navigaction controller's stack, the usual viewWillAppear / viewDidappear methods aren't called. If you want to ensure they're always called, just add the UINavigationContro 阅读全文
posted @ 2012-05-14 11:24 妙笔 阅读(482) 评论(0) 推荐(0) 编辑
摘要: 每个ios开发者对loadView和viewDidLoad肯定都很熟悉,虽然这两个函数使用上真的是非常简单,但是和类似的initWithNibName/awakeFromNib/initWithCoder放在一起还是非常容易让人混淆的.大前提是UIViewController有一个UIView.同时,需要理清两个概念,一、实例化一个类. 二、创建一个类。在XCode中创建一个类和实例化一个类很容易区分,但是在IB(Interface Builder)中有时候就会迷糊.其实也很好区分,孤零零地创建了一个nib文件,没有和其他可被实例化的类有直接或间接关系的时候,这个类或这些类(一个nib文件俺也 阅读全文
posted @ 2012-05-14 11:23 妙笔 阅读(582) 评论(0) 推荐(0) 编辑
摘要: 方法一,使用一个UIImageView实例做子视图,并且放最后面Objective-c代码 1 - (void)setBackgroundImage { 2 NSLog(@"setting bg image"); 3 UIImageView *customBackground = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"background.jpg"]]; 4 self.background = customBackground; 5 [customBackgrou... 阅读全文
posted @ 2012-05-14 11:21 妙笔 阅读(348) 评论(0) 推荐(0) 编辑
摘要: 详解iPhone下如何获取对象教程是本文要介绍的内容,主要是讲述iPhone下如何获取对象句柄和其父对象句柄,很详细的让我们去了解iphone中的对象,先来看详细内容。常规iPhone程序对象结构如下:对象个数对象类型1UIApplication 1UIApplicationDelegate/subclass 1,NUIViewController/subclass 1,NUIView/subclsss尽管有些书上说可以绕过UIViewController直接对UIView进行操作,但个人认为此层的作用用于管理视图和视图关系。下面分别对上述层次关系的对象类型进行学习。说明下,下面学习的东西仅和 阅读全文
posted @ 2012-05-14 11:19 妙笔 阅读(172) 评论(0) 推荐(0) 编辑
摘要: 详解iPhone下如何获取对象教程是本文要介绍的内容,主要是讲述iPhone下如何获取对象句柄和其父对象句柄,很详细的让我们去了解iphone中的对象,先来看详细内容。常规iPhone程序对象结构如下:对象个数对象类型1UIApplication 1UIApplicationDelegate/subclass 1,NUIViewController/subclass 1,NUIView/subclsss尽管有些书上说可以绕过UIViewController直接对UIView进行操作,但个人认为此层的作用用于管理视图和视图关系。下面分别对上述层次关系的对象类型进行学习。说明下,下面学习的东西仅和 阅读全文
posted @ 2012-05-14 11:16 妙笔 阅读(178) 评论(0) 推荐(0) 编辑
摘要: NSString 转换成NSData 对象 NSData* xmlData = [@"testdata" dataUsingEncoding:NSUTF8StringEncoding]; NSData 转换成NSString对象 NSData * data; NSString *result = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];NSData 转换成char*NSData *data;char *test=[data bytes];char* 转换成NSData对象byte* 阅读全文
posted @ 2012-05-14 11:12 妙笔 阅读(122) 评论(0) 推荐(0) 编辑
摘要: 最近有人问我关于什么时候用self.赋值的问题, 我总结了一下, 发出来给大家参考. 有什么问题请大家斧正. 关于什么时间用self. , 其实是和Obj-c的存取方法有关, 不过网上很多人也都这么解答的, 那它为什么和存取方法有关? 怎么有关的? 并没有多少人回答出来. 同时关于内存管理的内容, 请大家看旺财勇士的Objective-C内存管理总结~CC专版 , 有些东西我就不多解释了. 进入正题, 我们经常会在官方文档里看到这样的代码: 1 原文:http://www.weste.net/2011/2-23/74364.html 2 3 最近有人问我关于什么时候用self.赋值的问题,.. 阅读全文
posted @ 2012-05-08 18:13 妙笔 阅读(121) 评论(0) 推荐(0) 编辑
摘要: 1。如何读取UTF-8编码的文本文件?1 NSString *filePath = [[[NSBundle mainBundle] bundlePath] stringByAppendingPathComponent:fileName];2 [NSString stringWithContentsOfFile:filePath encoding:NSUTF8StringEncoding error:nil] 3 //当然也可以采用如下方法4 //NSData *data = [NSData dataWithContentsOfFile:filePath];5 /... 阅读全文
posted @ 2012-05-08 18:06 妙笔 阅读(330) 评论(0) 推荐(0) 编辑
摘要: tap是指轻触手势。类似鼠标操作的点击。从iOS 3.2版本开始支持完善的手势api:tap:轻触long press:在一点上长按pinch:两个指头捏或者放的操作pan:手指的拖动swipe:手指在屏幕上很快的滑动rotation:手指反向操作这为开发者编写手势识别操作,提供了很大的方便,想想之前用android写手势滑动的代码(编写android简单的手势切换视图示例),尤其感到幸福。这里写一个简单的tap操作。在下面视图的蓝色视图内增加对tap的识别:当用手指tap蓝色视图的时候,打印日志输出:代码很简单,首先要声明tap的recognizer:1 UITapGestureRecogn 阅读全文
posted @ 2012-05-08 11:53 妙笔 阅读(215) 评论(0) 推荐(0) 编辑