iOS入门时常用的一些代码段——2

来源:互联网 发布:mac系统复制粘贴快捷键 编辑:程序博客网 时间:2024/05/19 18:40
plist
- (
NSArray*) array
{
//  第一次加载时候
   
if(_array== nil){
//     NSBundle应用所在的文件夹
//    获取plist的全路径
      
NSString*path  = [[NSBundlemainBundle]pathForResource:@"imageData"ofType:@"plist"];

//     只要是方法名称后面是File那么要路径就是全路径(绝对路径)
          //加载plist文件
       _array = [NSArray arrayWithContentsOfFile:path];
    }
   return_array;

}


按钮注册事件
//其实和控件连线的IBAction 是一样的。 只是这个用于代码生成控件的情况
 //给按钮注册事件
    [downloadViewaddTarget:selfaction:@selector(downloadClick)forControlEvents:UIControlEventTouchUpInside];

//把某控件置于view的顶层

[self.view bringSubviewToFront:self.imageView];


定时器
NSTimer*timer = [NSTimertimerWithTimeInterval:2.0target:selfselector:@selector(nextImage)userInfo:nilrepeats:YES];
   self.timer= timer;                                                     

//tableview重新加载指定行
       
NSIndexPath*indexPath = [NSIndexPathindexPathForRow:alertView.taginSection:0];
        [self.tableViewreloadRowsAtIndexPaths:@[indexPath]withRowAnimation:UITableViewRowAnimationLeft];

//延时1秒钟执行

dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(1.0* NSEC_PER_SEC)),dispatch_get_main_queue(), ^{

//加载更多数据

[self.controller loadMoreData];self.loadingView.hidden= YES;

self.moreView.hidden= NO; });



0 0
原创粉丝点击