疑难杂症

 【254】【ios_VLC】

 VLC for iOS 2.3.0

 

 关于VLC配置问题,根据个人经验整理了一下,希望能帮到需要的朋友。

 

 

 官网链接:https://wiki.videolan.org/IOSCompile/

 

 百度云盘链接:http://pan.baidu.com/s/1bnEOXPH 密码:ur4l

 

 

【258】【应该竖屏,仅在视频播放页面横屏】

 在app delegate中,启动时,

 [userDefault setBool:NO forKey:@"userDefault_isAllowLandscape"];

 [userDefault synchronize];

 在app delegate中,通过一个本地保存的key进行判断,是否进行横屏

 - (NSUInteger)application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window

{

    // 全局的设置:允许竖屏+横屏

    NSUserDefaults *userDefault = [NSUserDefaults standardUserDefaults];

    BOOL isAllowLandscape = [userDefault boolForKey:@"userDefault_isAllowLandscape"];

    if (isAllowLandscape) {

        return UIInterfaceOrientationMaskPortrait|UIInterfaceOrientationMaskLandscape;

    } else {

        return UIInterfaceOrientationMaskPortrait;

    }

    

    

}

 在视频播放控制器中,更改本地保存的key即可

 【257】【模拟器上面 播放视频崩溃】

 iphone 4s  8.0系统的模拟器上面 播放视频:

 崩溃:

 Apr  9 11:44:39 [jun] rtcreporting[57158] : logging starts...

 Apr  9 11:44:39 [jun] rtcreporting[57158] : setMessageLoggingBlock: called

 原因:

 在模拟器上面播放视频

 解决办法:

 去掉全局断点,这是一个bug

 

 

 

【289】【隐藏导航条】

// 导航控制器的显示和隐藏【提示,如果使用navigationBarHidden属性,侧滑会出问题】

- (void)viewWillAppear:(BOOL)animated

{

    [super viewWillAppear:animated];

    self.navigationController.navigationBar.hidden = YES;

}

- (void)viewWillDisappear:(BOOL)animated

{

    [super viewWillDisappear:animated];

    self.navigationController.navigationBar.hidden = NO;

}

 

 

【301】【弹出动画】

注意在viewDidAppear调用

- (void)addKeyAnimation

{

    CAKeyframeAnimation * animation;

    animation = [CAKeyframeAnimation animationWithKeyPath:@"transform"];

    animation.duration = 0.5;

    animation.delegate = self;

    animation.removedOnCompletion = YES;

    animation.fillMode = kCAFillModeForwards;

    

    NSMutableArray *values = [NSMutableArray array];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.1, 0.1, 1.0)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.2, 1.2, 1.0)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(0.9, 0.9, 0.9)]];

    [values addObject:[NSValue valueWithCATransform3D:CATransform3DMakeScale(1.0, 1.0, 1.0)]];

    

    animation.values = values;

    [_contentView.layer addAnimation:animation forKey:nil];

}

 

 

【304】【cell侧滑ime删除】

1.dataSource的方法:

- (void)tableView:(UITableView *)tableView commitEditingStyle:(UITableViewCellEditingStyle)editingStyle forRowAtIndexPath:(NSIndexPath *)indexPath

此方法就是给一个空的实现滑动也会出现删除按钮!!

2. 必须先删除数据源

[blockSelf.arrayData removeObjectAtIndex:indexPath.row];

// 再删除view

[blockSelf.tableView deleteRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];

 

[blockSelf.tableView reloadData];

 

 

【327】【金额用NSNumber接收,必须strong引用 否则 内存释放,崩掉】

//金额

@property (nonatomic,strong) NSNumber *orderPrice;

 

double currentPrice = [model.FCurrentPrice doubleValue];

_topView.currentLabel.text = [NSString stringWithFormat:@"¥%.02lf",currentPrice];

 

 

【343】【奇怪的bug】

问题描述:

1、tableView是通过IB,并且有自动布局;

2、headView是通过代码创建的

3、给tableView加headView,没有问题

4、给tableView加footerView,当用代码创建时,也没有问题

5、但是:当footerView是用自动布局时,tableView首次展示时,footView高度为0;

但是,当jump到一个控制器,并且再次返回时,tableView再次显示,此时footView高度正常了。。。

问题原因:

猜测是:tableView的自动布局影响的

解决方法:

当前 想到的是:线程延迟几秒再给tableView设置footView

self.tableView.tableHeaderView = self.headView;

_footerView = [RowView RowView];

// 这里加个延迟,不然会高度为0,应该是自动布局导致的问题

kWeakSelf

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

    kStrongSelf

    strongSelf.tableView.tableFooterView = _footerView;

    [UIView animateWithDuration:5 animations:^{

        [strongSelf.view layoutIfNeeded];

        [strongSelf.tableView layoutIfNeeded];

    }];

});

 

 

【348】【判断是否安装weixin】

[WXApi isWXAppInstalled]方法无效

使用下面这个

if ([[UIApplication sharedApplication] canOpenURL:[NSURL URLWithString:@"weixin://"]])

{

    NSLog(@"OK weixin://");

}

 

 

【381】【给分类添加属性】

// Declaration

 

@interface MyObject (ExtendedProperties)

@property (nonatomic, strong, readwrite) id myCustomProperty;

@end Implementation

 

static void * MyObjectMyCustomPorpertyKey = (void *)@"MyObjectMyCustomPorpertyKey";

 

@implementation MyObject (ExtendedProperties)

 

- (id)myCustomProperty

{

    return objc_getAssociatedObject(self, MyObjectMyCustomPorpertyKey);

}

 

- (void)setMyCustomProperty:(id)myCustomProperty

{

    objc_setAssociatedObject(self, MyObjectMyCustomPorpertyKey, myCustomProperty, OBJC_ASSOCIATION_RETAIN_NONATOMIC);

}

 

@end

 

 

【382】【带暂停和继续的NSTimer】

#import

 

@interface NSTimer (Pause)

@property (nonatomic, strong, readwrite) NSString *state;

-(void)pause;

-(void)resume;

@end

///////////////////////////////////////////////////////////////////////////

#import "NSTimer+Pause.h"

#import

static void *state = (void *)@"state";

@implementation NSTimer (Pause)

-(void)pause

{

    if (![self isValid]) {

        return ;

    }

    [self setFireDate:[NSDate distantFuture]]; //如果给我一个期限,我希望是4001-01-01 00:00:00 +0000

}

-(void)resume

{

    if (![self isValid]) {

        return ;

    }

    [self setFireDate:[NSDate date]];

}

- (NSString *)state

{

    return objc_getAssociatedObject(self, state);

}

- (void)setState:(NSString *)s

{

    objc_setAssociatedObject(self, state, s, OBJC_ASSOCIATION_RETAIN_NONATOMIC);

}

@end

posted @ 2016-06-08 15:12  呦呦Code  阅读(182)  评论(0)    收藏  举报