开发直播app 软件时iOS端广告功能设置

发布时间:2020-06-29 20:13:48 作者:云豹短视频
来源:网络 阅读:340

在直播app 软件中启动广告与引导图是目前主流app中非常常见的功能,这里简单提供一个开发直播app 软件时iOS端实现app引导图或者启动广告的思路,新建一个viewcontroller来实现。
首先,appDelegate里面稍作改动,添加如下方法

- (void)openGuideVC{
    GuideVC *FirstVC = [[GuideVC alloc] init];
    UINavigationController *firstNav = [[UINavigationController alloc] initWithRootViewController:FirstVC];
    self.window.rootViewController = firstNav;
    [self.window makeKeyAndVisible];
}
- (void)openHomeVc{
    self.window.rootViewController = [[UINavigationController alloc] initWithRootViewController:[[RookieTabBarController alloc] init]];
    [self.window makeKeyAndVisible];
}

其中,第一个方法是打开引导图的方法,第二个是我们原本的设置的rootVC,一般是登录页或者首页。现在直接调用第一个方法,先打开引导页,在引导页展示完成或者用户点击跳过之后,执行第二个方法进入app. 接下来看一下GuideVC里面我们需要做什么。

  //创建图片
    image = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, _window_width, _window_height)];
    image.image = [self getLaunchImage];
    image.userInteractionEnabled = YES;
    [self.view addSubview:image];
    //创建跳过按钮
    btn = [UIButton buttonWithType:UIButtonTypeCustom];
    [btn setTitle:nil forState:UIControlStateNormal];
    [btn setFrame:CGRectMake(SCREEN_WIDTH - 85, _window_height - 80, 70, 25)];
    [btn addTarget:self action:@selector(button:) forControlEvents:UIControlEventTouchUpInside];
    [btn setTitle:@"5秒" forState:UIControlStateNormal];
    btn.titleLabel.font = SYS_Font(13);
    btn.layer.masksToBounds = YES;
    btn.layer.cornerRadius = 25.0 / 2;
    btn.layer.borderColor = [UIColor whiteColor].CGColor;
    btn.layer.borderWidth = 1.5;
    [image addSubview:btn];
    btn.userInteractionEnabled = NO;
    [self getData];`

如上,在guideVC的viewdidload中,创建一张图片和一个跳过按钮,如果我们要展示的图片需要从网络加载,那么为了避免加载过程中展示空白,先展示app的启动图,然后在getData方法里面获取到图片之后,再给image赋值。然后在点击跳过的时候,执行下面的方法打开app.

 AppDelegate *appdelegate = (AppDelegate *)[UIApplication sharedApplication].delegate;
[appdelegate openHomeVc];

这里是一种最简单的情况,当然我们可以根据这种思路去实现一些更为复杂的功能,例如添加可滑动的多张图片、添加视频播放、添加倒计时等等,在此就不一一列举了,这就是开发直播app 软件时iOS端广告功能的设置介绍。
声明:本篇文章为小编原创文章,转载请注明出处及作者。

推荐阅读:
  1. iOS APP提交App Store审核注意事项
  2. HTML5开发APP有哪些优缺点

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

开发直播 app 软件

上一篇:C#多线程

下一篇:王高利:Redis入门

相关阅读

您好,登录后才能下订单哦!

密码登录
登录注册
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》