iOS development project summary

Disclaimer: This article is a blogger original article, reproduced, please indicate the source of the article. https://blog.csdn.net/SunFlowerInRain/article/details/81087514

webview development process stepped pit;

Turn off the audio sound when 1.webview closed issue;
take time to start to take @"about:blank"way off, found that in the event webviewafter the jump gobackblank page before came back loaded, so this approach has limitations;
2. the use of interaction with JS method;
before the page is closed, JS direct call to close video playback method to achieve close audio playback;
3.webview loading two URl will complain that a page has not finished loading the URL began to load another page URL, this time webview will give an error;

Audio playback control problems

1. Audio loop problems;
by listening to the audio player to complete the action, the audio player call-back to the place to start;

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(playerItemDidPlayToEnd:) name:AVPlayerItemDidPlayToEndTimeNotification object:nil];
-(void)rerunPlayVideo{
    if (!self.player) {
        return;
    }
    CGFloat a=0;
    NSInteger dragedSeconds = floorf(a);
    CMTime dragedCMTime = CMTimeMake(dragedSeconds, 1);
    [self.player seekToTime:dragedCMTime];
    [self.player pause];
}

. Countdown to the end of the control problem

1. GCD control by way of the countdown;
the timer countdown audio control, but requires processing of other events before the end of the countdown, and prevents the page to other pages has entered the timer has not been released, so often there will be Ben collapse ;

- (void)createTimer {
    //设置倒计时时间
    //__block 如果修饰指针时,指针相当于弱引用,指针对指向的对象不产生引用计数的影响
    __block int timeout = 60;
    dispatch_queue_t global = dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0);
    dispatch_source_t timer = dispatch_source_create(DISPATCH_SOURCE_TYPE_TIMER, 0, 0, global);
    // 设置触发的间隔时间
    dispatch_source_set_timer(timer, DISPATCH_TIME_NOW, 1.0 * NSEC_PER_SEC, 0 * NSEC_PER_SEC);
    //1.0 * NSEC_PER_SEC  代表设置定时器触发的时间间隔为1s
    //0 * NSEC_PER_SEC    代表时间允许的误差是 0s
    //block内部 如果对当前对象的强引用属性修改 应该使用__weak typeof(self)weakSelf 修饰  避免循环调用
    WS(ws);
    //设置定时器的触发事件
    dispatch_source_set_event_handler(timer, ^{
        //1. 每调用一次 时间-1s
        timeout --;
        if (timeout < 0) {
            dispatch_source_cancel(timer);
            //MRC下需要释放,这里不需要
            //   dispatch_realse(timer);
            //在主线程中对button进行修改操作
            dispatch_async(dispatch_get_main_queue(), ^{

        }else {
            //处于正在倒计时,在主线程中刷新button上的title,时间-1秒
            dispatch_async(dispatch_get_main_queue(), ^{

            });
        }
    });
    dispatch_resume(timer);
}

Font attribute set the font spacing

1. Set the font spacing attribute NSKernAttributeName by this method;

NSMutableAttributedString *attStr = [[NSMutableAttributedString alloc] initWithString:allStr];
        [attStr addAttribute:NSKernAttributeName value:@9.2 range:[allStr rangeOfString:content]];

Guess you like

Origin blog.csdn.net/SunFlowerInRain/article/details/81087514