IOS实现开机启动欢迎页广告倒计时源代码

@implementation AppDelegate的 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions


NSString * documentsDirectoryPath = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) objectAtIndex:0];


        UIImage * imageFromWeb = [self loadImage:@"MyImage" ofType:@"jpg" inDirectory:documentsDirectoryPath];

                               

        if (imageFromWeb) {

            WCImageView *imageV = [[WCImageView alloc] initWithFrame:self.window.frame];

            imageV.image = imageFromWeb;

            [imageV startShowingPage];

        }

        else {

            [WCImageView loadingImageDataFromWeb];

            

        }

其中方法:

-(UIImage *) loadImage:(NSString *)fileName ofType:(NSString *)extension inDirectory:(NSString *)directoryPath {

    UIImage * result = [UIImage imageWithContentsOfFile:[NSString stringWithFormat:@"%@/%@.%@", directoryPath, fileName, extension]];

    

    return result;

}



WCImageView类实现:


#import <UIKit/UIKit.h>

#import "KKProgressTimer.h"


@interface WCImageView : UIImageView <KKProgressTimerDelegate>


- (void)startShowingPage;

+ (void)loadingImageDataFromWeb;


@end



#import "WCImageView.h"

#import "MFService.h"

#import "Utilities.h"

#import "UIColor+extend.h"


#define DEFAULT_TIMEROUT 4.f

static UIWindow *__sheetWindow = nil;

@implementation WCImageView

{

    KKProgressTimer *timer1;

}

- (id)initWithFrame:(CGRect)frame {

    if (self = [super initWithFrame:frame]) {

        

    }

    return self;

}


#pragma mark - PUBLIC METHODS

- (void)startShowingPage {

    [self addWindowAction];

}


+ (void)loadingImageDataFromWeb {

    NSString *timestamp = [Utilities getTimestamp];

    

    NSDictionary *paramters = @{ @"spid":SPID, @"timestamp":timestamp,

                                @"hash":[Utilities getHash:timestamp],

                                @"citycode":@""};

    

    NSDictionary *serviceDict = [[MFServiceList manager] queryActionWithId:NO_18_queryPageThemes];

    MFService *service = [[MFService alloc] initWithDataDictionary:serviceDict];

    [service queryWith:paramters success:^(id result) {

        

        NSDictionary *dict = (NSDictionary *)result;

        NSDictionary *data = dict[@"data"];

        NSDi

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
实现小程序欢迎一张图片然后倒计时三秒进入首的方法如下: 1. 在小程序的 app.json 文件中配置欢迎的路径,例如: ```json { "pages": [ "pages/welcome/welcome", "pages/home/home" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "小程序欢迎", "navigationBarTextStyle": "black" }, "tabBar": {} } ``` 2. 在小程序的 welcome 面的 wxml 文件中添加一个图片标签,用于显示欢迎的图片,例如: ```html <image src="/images/welcome.jpg" mode="aspectFit"></image> ``` 3. 在小程序的 welcome 面的 js 文件中使用定时器实现倒计时功能,并在倒计时结束后跳转到首,例如: ```javascript Page({ onLoad: function () { let that = this let countdown = 3 let timer = setInterval(function () { countdown-- if (countdown == 0) { clearInterval(timer) wx.switchTab({ url: '/pages/home/home' }) } }, 1000) } }) ``` 其中,wx.switchTab 方法用于跳转到首,需要在 app.json 文件中配置首的路径。 注意:在小程序的 app.json 文件中需要把 welcome 面设置为启动,例如: ```json { "pages": [ "pages/welcome/welcome", "pages/home/home" ], "window": { "backgroundTextStyle": "light", "navigationBarBackgroundColor": "#fff", "navigationBarTitleText": "小程序欢迎", "navigationBarTextStyle": "black" }, "tabBar": {}, "onLaunch": "pages/welcome/welcome" } ``` 以上就是小程序欢迎一张图片然后倒计时三秒进入首实现方法。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值