自学知识(五)

1.网络请求显示,请求成功显示,请求失败隐藏:

//显示状态栏的网络指示器

    [UIApplication sharedApplication].networkActivityIndicatorVisible = YES;

 

2.是否显示引导页:

 1 //是否显示引导页
 2 -(void)showGuiView {
 3     
 4     //获得当前版本号
 5     NSString *currentVersion = [NSBundle mainBundle].infoDictionary[@"CFBundleShortVersionString"];
 6     //沙盒版本号
 7     NSString *lastVersion = [[NSUserDefaults standardUserDefaults] stringForKey:@"CFBundleShortVersionString"];
 8     
 9     if (![currentVersion isEqualToString:lastVersion]) {
10         XFGuideView *guideView = [XFGuideView guideView];
11         guideView.frame = self.window.bounds;
12         [self.window addSubview:guideView];
13         
14         [[NSUserDefaults standardUserDefaults] setObject:currentVersion forKey:@"CFBundleShortVersionString"];
15         //马上写入沙盒
16         [[NSUserDefaults standardUserDefaults] synchronize];
17         
18     }
19 }

 

3.内存警告停止下载图片:

1 //当收到Received memory warning.会调用次方法
2 -(void)applicationDidReceiveMemoryWarning:(UIApplication *)application {
3     SDWebImageManager *mgr = [SDWebImageManager sharedManager];
4     //取消下载
5     [mgr cancelAll];
6     //清空缓存
7     [mgr.imageCache clearMemory];
8 
9 }

 

4.在子类化单元格类中:

 

// 从队列里面复用时调用

- (void)prepareForReuse {

    

    [super prepareForReuse];

    [_videoView reset];

    [_voiceView reset];

}

 

5.UIMenuController的使用:

-(IBAction)panGestureTop:(UILongPressGestureRecognizer *)longPress

02.{
03. 
04.UIMenuItem * itemPase = [[UIMenuItem alloc] initWithTitle:@"复制" action:@selector(copyimage)];
05.UIMenuItem * itemTrans = [[UIMenuItem alloc] initWithTitle:@"转发" action:@selector(trans)];
06.UIMenuItem * itemCollect = [[UIMenuItem alloc] initWithTitle:@"收藏" action:@selector(collect)];
07.UIMenuItem * itemJoin = [[UIMenuItem alloc] initWithTitle:@"加入" action:@selector(join)];
08. 
09.UIMenuController * menuController = [UIMenuController sharedMenuController];
10.[menuController setMenuItems: @[itemPase,itemCollect,itemTrans,itemJoin]];
11. 
12.CGPoint location = [longPress locationInView:[longPress view]];
13.CGRect menuLocation = CGRectMake(location.x, location.y, 0, 0);
14.[menuController setTargetRect:menuLocation inView:[longPress view]];
15.menuController.arrowDirection = UIMenuControllerArrowDown;
16. 
17.[menuController setMenuVisible:YES animated:YES];
18. 
19.}

 

6.对界面一样的可以复用控制器,简化代码,在控制器设置三目条件即可.

 

 

 每天进步一点点!!!

 

posted on 2016-04-05 16:55  玉思盈蝶  阅读(213)  评论(0编辑  收藏  举报

导航