08 2012 档案
摘要://以前一直不知道多线程是个什么东西,为什么要用到线程。直到项目里遇到请求XML时。当数据加载或刷新时界面就会卡。也就是主线程堵塞。后来终于把这个问题给解决了。 //初始化 _operationQueue = [[NSOperationQueue alloc]init];//设置每秒请求一次 。在这里selector:@selector(threadTestN)后面注意如果threadTestN没有带冒号,表示这个方法不带参数。如果带上了冒号":"表示这个方法是有参数的 NSTimer *timer = [NSTimer scheduledTimerWithTimeInte
阅读全文
摘要:xcode->preferences->text editing->display options->show line numbers
阅读全文
摘要://开始触发键盘-(BOOL)textViewShouldBeginEditing:(UITextView *)textView{ return YES;}//在触发键盘之前可以触发一些必要的事件。-(void)textViewDidBeginEditing:(UITextView *)textView{ NSLog(@"Begin");/* UIBarButtonItem *done = [[[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self..
阅读全文
摘要://设置tableViewcell里uilabel、图片高度 CGSize tbvContentSizeForheight = [cell.resultNoticeTableContent.text sizeWithFont:cell.resultNoticeTableContent.font]; CGSize tbvContentSizeForLines = [cell.resultNoticeTableContent.text sizeWithFont:cell.resultNoticeTableContent.font constrainedToSize:CGSizeMak...
阅读全文
摘要:contentSize是scrollview可以滚动的区域,比如frame = (0 ,0 ,320 ,480) contentSize = (320 ,960),代表你的scrollview可以上下滚动,滚动区域为frame大小的两倍。contentOffset是scrollview当前显示区域顶点相对于frame顶点的偏移量,比如上个例子你拉到最下面,contentoffset就是(0 ,480),也就是y偏移了480contentInset是scrollview的contentview的顶点相对于scrollview的位置,例如你的contentInset = (0 ,100),那么你的
阅读全文
摘要:今天突然遇到了一个这样的错误。Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<ContentViewController 0x4528a0> setValue:forUndefinedKey:]:this class is not key value coding-compliant for the key digitPressed弄了半天,代码也没有错误。后来还是找到了。是因为。当前的这个视图。View有一些控件有多余的关联。把它删除掉就行了。第一次
阅读全文
摘要://在- (void)viewDidLoad方法中加入//加载后自动定位到某一行 NSIndexPath *idxPath = [NSIndexPath indexPathForRow:8 inSection:0];//定位到第8行 [self.resultCommunityTableview scrollToRowAtIndexPath:idxPath atScrollPosition:UITableViewScrollPositionMiddle animat...
阅读全文
摘要:UIColor *color = [UIColor colorWithPatternImage:[UIImage imageNamed:@"半透明title.png"]]; uilabel.backgroundColor = color;
阅读全文
摘要://最先进的是这个 返回一共有多少行!- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{ NSLog(@"111"); tableView.contentInset = UIEdgeInsetsMake(0, 0, -144, 0); //AppDelegate为一个代理类。 AppDelegate *app = [[UIApplication sharedApplication]delegate]; int count = [app....
阅读全文
摘要:这几个都是在ios程序中,经常会注意到的一些小细节,能否真正了解这些,对写ios程序也有很大的好处。frame 是UIView中表示此view的一个矩形面积,包括了view在它的superview中的一些几何上的标识。有起始坐标,也就是origin(CGPoint)和这个矩形面积的宽(width)和高(height)bounds 每个view,除了有对应它的superview的相关坐标外,它自己也有对应它自己的几何坐标,所以bounds就是标识它自己坐标关系的一个标识,它有和frame一样的属性,但在数值上会有些不同。center 是一个view的中心,默认是这个view对应superview
阅读全文
摘要://AppDelegate.h 头文件 #import <UIKit/UIKit.h>@class SwitchViewController;@interface AppDelegate : UIResponder <UIApplicationDelegate>{ UIApplication *mApp; //新建一个UIApplication对象}@property (strong, nonatomic) UIWindow *window;@property (nonatomic, retain) SwitchViewController *switchViewCon
阅读全文