ITeye博客

2014 年文章归档

共 8 篇文章

ios多线程

最近写了一个东西需要加载网络上的图片,运行的时候一直卡到一个界面特别慢,所以学习了一下多线程,我写的代码如下 -(void)imageView:(NSString *)imageHttp :(id)view { dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ UIImage *image = [uiimage imagewithdata:[nsdata datawithcontentsofurl:[nsurl urlwithstring:imagehttp]]]; dispatc…

2014-11-27 14:35 · 基础学习

取出数组中的值

在写程序的时候,遇到一个问题,想把数组中的a,b添加到label中,可是如果依次取的话添加上去就会重叠,我就想着怎么能一次把所有的object值全取出,后来才知道这个想法实现不了,纠结了一晚上 :( ,但是还是可以解决的,只需要一句话,废话不多说,直接上代码 NSString *string =[ [a,b] componentsJoinedByString:@","];

2014-11-01 21:08 · 基础学习

解析json获取数据

NSError *error; NSURLRequest *request = [nsurlrequest requestwithurl:[nsurl urlwithstring:@"https://api.douban.com/v2/book/search?tag=computer"]]; //将请求的url数据放到NSData对象中 NSData *response = [nsurlconnection sendsynchronousrequest:request returningresponse:nil error:nil]; //IOS5自带解析类NSJSONSerializati…

2014-11-01 20:57 · 基础学习

cell重用问题

解决问题之前,在cell上添加了label,但是给label添加label.text之后滑动时即用到cell重用时label的内容总是重叠,从网上搜了好多,现在终于解决了,总结一下我用的方法:就是给重用的cell也设置不同的标示符。首先,对于tableviewcell static NSString *CellIdentifier =@"Cell"; UITableViewCell *cell = [tableview dequeuereusablecellwithidentifier:cellidentifier]; if (cell == nil) { cell = [[uitablev…

2014-11-01 20:44 · 基础学习

保存并获取数据

在IOS开发过程中,经常会遇到数据保存的问题,现在主要说一下用write方法保存数据,并在需要使用时获取数据,使用write to file方法可以使数据永久的保存在磁盘中,具体方法: NSArray*paths=NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES); NSString *path=[paths objectatindex:0]; NSLog(@"path = %@",path); NSString *FileName=[documentdirectory stringbya…

2014-09-27 19:38 · 基础学习

UINavigationController实现页面跳转

总结一下利用navigationController pushviewController 的方式实现页面跳转: 设置导航栏: @interface AppDelegate : UIResponder <UIApplicationDelegate> @property (strong, nonatomic) UIWindow *window; @end - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { ViewContro…

2014-09-19 20:31 · 基础学习

tableviewcell添加label、button

1.给tableviewcell添加label,首先 CGRect labelRect = CGRectMake(X, Y,length, width);//x、y表示位置 UILabel *label = [[uilabel alloc] initWithFrame:labelRect]; 然后可以定义label的一些属性 label.backgroundColor = ; //设置背景色 label.text = @"Hello World"; //设置内容 label.textColor = ; //文本颜色 label.backgroundColor = ; //设置label的背景…

2014-09-13 22:02 · 基础学习

简单表视图并实现添加数据

1.基础:表用于显示数据列表。数据列表中的每项都由行表示。表视图是显示表数据的视图对象,它是UITableView类的一个实例,表中的每个可见行(表视图单元)都由UITableViewCell类实现。 2.实现表视图。 首先说明一下数据源(datasource)和委托(delegate) 在头文件中需要添加以下代码:<UITableViewDelegate,UITableViewDataSource>,它的作用是让类遵从两个协议,类需要使用这两个协议来充当表视图的委托和数据源,然后声明一个数组用于放置将要显示的数据。UITableView需要一个数据源(dataSource)来显示数据,UI…

2014-09-10 19:21 · 基础学习