Authored by 盖剑秋

End view.

... ... @@ -24,6 +24,7 @@
/* Begin PBXBuildFile section */
2E2E2D791D0E8B290067D118 /* YH_HTTPRequestSerializer.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E2E2D781D0E8B290067D118 /* YH_HTTPRequestSerializer.m */; };
2E2E2D7C1D0E8BD90067D118 /* NSString+M16String.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E2E2D7B1D0E8BD90067D118 /* NSString+M16String.m */; };
2E3F97D31D767A0800DCB96B /* YH_EndViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E3F97D21D767A0800DCB96B /* YH_EndViewController.m */; };
2E487ACC1D66AA5D009DBB6D /* UIView+YOHO.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E487ACB1D66AA5D009DBB6D /* UIView+YOHO.m */; };
2E487AD71D66AA94009DBB6D /* NSMutableArray+QueueAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E487ACE1D66AA94009DBB6D /* NSMutableArray+QueueAdditions.m */; };
2E487AD81D66AA94009DBB6D /* NSString+LIVE.m in Sources */ = {isa = PBXBuildFile; fileRef = 2E487AD01D66AA94009DBB6D /* NSString+LIVE.m */; };
... ... @@ -198,6 +199,8 @@
2E2E2D781D0E8B290067D118 /* YH_HTTPRequestSerializer.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YH_HTTPRequestSerializer.m; sourceTree = "<group>"; };
2E2E2D7A1D0E8BD90067D118 /* NSString+M16String.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSString+M16String.h"; sourceTree = "<group>"; };
2E2E2D7B1D0E8BD90067D118 /* NSString+M16String.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "NSString+M16String.m"; sourceTree = "<group>"; };
2E3F97D11D767A0800DCB96B /* YH_EndViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = YH_EndViewController.h; sourceTree = "<group>"; };
2E3F97D21D767A0800DCB96B /* YH_EndViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = YH_EndViewController.m; sourceTree = "<group>"; };
2E487ACA1D66AA5D009DBB6D /* UIView+YOHO.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "UIView+YOHO.h"; sourceTree = "<group>"; };
2E487ACB1D66AA5D009DBB6D /* UIView+YOHO.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = "UIView+YOHO.m"; sourceTree = "<group>"; };
2E487ACD1D66AA94009DBB6D /* NSMutableArray+QueueAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = "NSMutableArray+QueueAdditions.h"; sourceTree = "<group>"; };
... ... @@ -597,6 +600,8 @@
2E4D5FC11D057C6100D508BB /* YH_RootViewController.m */,
2EFAE0A81D740EDD00D489BD /* YH_RoomSecretViewController.h */,
2EFAE0A91D740EDD00D489BD /* YH_RoomSecretViewController.m */,
2E3F97D11D767A0800DCB96B /* YH_EndViewController.h */,
2E3F97D21D767A0800DCB96B /* YH_EndViewController.m */,
2E5FA88F1D06D2FD00920FB4 /* YH_ChannelModel.h */,
2E5FA8901D06D2FD00920FB4 /* YH_ChannelModel.m */,
31CCA53B1D2613D800ADF9F0 /* UIViewAdditions.h */,
... ... @@ -1207,6 +1212,7 @@
2E487B061D66B05F009DBB6D /* YH_DNSIP.m in Sources */,
2E487B2B1D66B273009DBB6D /* UIButton+YOHO.m in Sources */,
2EB6705C1D19088A00E91AAE /* SDWebImageDownloader.m in Sources */,
2E3F97D31D767A0800DCB96B /* YH_EndViewController.m in Sources */,
2EB66FF51D18EF2F00E91AAE /* EXTScope.m in Sources */,
2E487B291D66B273009DBB6D /* NSMutableArray+YOHO.m in Sources */,
2E5FA8941D06DB2F00920FB4 /* YH_ChannelCell.m in Sources */,
... ...
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "home_btn_close@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "home_btn_close@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
... ...
{
"images" : [
{
"idiom" : "universal",
"scale" : "1x"
},
{
"idiom" : "universal",
"filename" : "home_icon_roomkey@2x.png",
"scale" : "2x"
},
{
"idiom" : "universal",
"filename" : "home_icon_roomkey@3x.png",
"scale" : "3x"
}
],
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
... ...
{
"info" : {
"version" : 1,
"author" : "xcode"
}
}
\ No newline at end of file
... ...
//
// YH_EndViewController.h
// YohoLive
//
// Created by 盖剑秋 on 16/8/31.
// Copyright © 2016年 YOHO!. All rights reserved.
//
#import <UIKit/UIKit.h>
@interface YH_EndViewController : UIViewController
+ (void)showInController:(UIViewController *)aController secret:(NSString *)secret completionBlock:(void(^)(NSDictionary *dic, BOOL success))block;
- (void)setCompletionBlock:(void(^)(NSDictionary *dic, BOOL success))block;
@end
... ...
//
// YH_EndViewController.m
// YohoLive
//
// Created by 盖剑秋 on 16/8/31.
// Copyright © 2016年 YOHO!. All rights reserved.
//
#import "YH_EndViewController.h"
@interface YH_EndViewController()
- (void)setRoomSecret:(NSString *)secret;
@end
@implementation YH_EndViewController
{
void (^completionBlock)(NSDictionary *dic, BOOL success);
UITextField *textField;
UIButton *startButton;
UILabel *secretLabel;
}
+ (void)showInController:(UIViewController *)aController secret:(NSString *)secret completionBlock:(void (^)(NSDictionary *, BOOL))block {
YH_EndViewController *ctrler = [YH_EndViewController new];
[ctrler setCompletionBlock:block];
[aController.view addSubview:ctrler.view];
[ctrler setRoomSecret:secret];
[aController addChildViewController:ctrler];
}
- (instancetype)init {
if (self = [super init]) {
}
return self;
}
- (void)setRoomSecret:(NSString *)secret {
secretLabel.text = secret;
}
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0];
UIView *bg = [UIView new];
[self.view addSubview:bg];
bg.frame = CGRectMake(0, 0, 280, 250);
bg.center = self.view.center;
bg.backgroundColor = [UIColor whiteColor];
CGRect frame = bg.frame;
frame.origin.y = 170;
bg.frame = frame;
bg.userInteractionEnabled = YES;
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 280, 19)];
titleLabel.font = [UIFont systemFontOfSize:18];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.text = @"房间秘钥";
[bg addSubview:titleLabel];
secretLabel = [[UILabel alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(titleLabel.frame)+24, 250, 40)];
secretLabel.font = [UIFont systemFontOfSize:14];
secretLabel.textAlignment = NSTextAlignmentCenter;
[bg addSubview:secretLabel];
startButton = [UIButton buttonWithType:UIButtonTypeCustom];
startButton.frame = CGRectMake(15, CGRectGetMaxY(secretLabel.frame)+ 40, 250, 40);
startButton.titleLabel.font = [UIFont boldSystemFontOfSize:17];
[startButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
startButton.backgroundColor = [UIColor blackColor];
[bg addSubview:startButton];
[startButton addTarget:self action:@selector(startButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[startButton setTitle:@"结束直播" forState:UIControlStateNormal];
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
closeButton.frame = CGRectMake(280-18-8, 8, 18, 18);
[closeButton setImage:[UIImage imageNamed:@"home_btn_close"] forState:UIControlStateNormal];
[bg addSubview:closeButton];
[closeButton addTarget:self action:@selector(closeButtonPressed) forControlEvents:UIControlEventTouchUpInside];
}
- (void)startButtonPressed {
if (completionBlock) {
completionBlock(nil,YES);
}
[self closeButtonPressed];
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[UIView animateWithDuration:0.3 animations:^{
self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
} completion:^(BOOL finished) {
}];
}
- (void)closeButtonPressed {
[UIView animateWithDuration:0.3 animations:^{
self.view.alpha = 0;
} completion:^(BOOL finished) {
[self.view removeFromSuperview];
[self removeFromParentViewController];
}];
}
- (void)setCompletionBlock:(void (^)(NSDictionary *, BOOL))block {
completionBlock = [block copy];
}
@end
... ...
... ... @@ -8,9 +8,15 @@
#import "YH_RoomSecretViewController.h"
@interface YH_RoomSecretViewController()
@end
@implementation YH_RoomSecretViewController
{
void (^completionBlock)(NSDictionary *dic, BOOL success);
UITextField *textField;
UIButton *startButton;
}
+ (void)showInController:(UIViewController *)aController completionBlock:(void (^)(NSDictionary *, BOOL))block {
... ... @@ -33,14 +39,84 @@
[self.view addSubview:bg];
bg.frame = CGRectMake(0, 0, 280, 250);
bg.center = self.view.center;
bg.backgroundColor = [UIColor whiteColor];
CGRect frame = bg.frame;
frame.origin.y = 170;
bg.frame = frame;
bg.userInteractionEnabled = YES;
UILabel *titleLabel = [[UILabel alloc] initWithFrame:CGRectMake(0, 50, 280, 19)];
titleLabel.font = [UIFont systemFontOfSize:18];
titleLabel.textAlignment = NSTextAlignmentCenter;
titleLabel.text = @"房间秘钥";
[bg addSubview:titleLabel];
UIView *secretBg = [[UIView alloc] initWithFrame:CGRectMake(15, CGRectGetMaxY(titleLabel.frame)+44, 250, 40)];
secretBg.backgroundColor = [UIColor groupTableViewBackgroundColor];
[bg addSubview:secretBg];
UIImageView *keyImage = [[UIImageView alloc] initWithFrame:CGRectMake(8, 12, 15, 16)];
keyImage.image = [UIImage imageNamed:@"home_icon_roomkey"];
[secretBg addSubview:keyImage];
UIView *bar = [[UIView alloc] initWithFrame:CGRectMake(31, 12, 0.5, 16)];
bar.backgroundColor = [UIColor lightGrayColor];
[secretBg addSubview:bar];
textField = [[UITextField alloc] initWithFrame:CGRectMake(35, 0, 210, 40)];
textField.font = [UIFont systemFontOfSize:14];
textField.keyboardType = UIKeyboardTypeNumberPad;
textField.keyboardAppearance = UIKeyboardAppearanceDark;
[secretBg addSubview:textField];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(textDidChange:) name:UITextFieldTextDidChangeNotification object:nil];
startButton = [UIButton buttonWithType:UIButtonTypeCustom];
startButton.frame = CGRectMake(15, CGRectGetMaxY(secretBg.frame)+20, 250, 40);
startButton.titleLabel.font = [UIFont boldSystemFontOfSize:17];
[startButton setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
startButton.backgroundColor = [UIColor lightGrayColor];
[bg addSubview:startButton];
[startButton addTarget:self action:@selector(startButtonPressed) forControlEvents:UIControlEventTouchUpInside];
[startButton setTitle:@"开始直播" forState:UIControlStateNormal];
UIButton *closeButton = [UIButton buttonWithType:UIButtonTypeCustom];
closeButton.frame = CGRectMake(280-18-8, 8, 18, 18);
[closeButton setImage:[UIImage imageNamed:@"home_btn_close"] forState:UIControlStateNormal];
[bg addSubview:closeButton];
[closeButton addTarget:self action:@selector(closeButtonPressed) forControlEvents:UIControlEventTouchUpInside];
}
- (void)textDidChange:(NSNotification *)sender {
UITextField *txtFild = sender.object;
if (txtFild.text.length) {
startButton.backgroundColor = [UIColor blackColor];
}else {
startButton.backgroundColor = [UIColor lightGrayColor];
}
}
- (void)startButtonPressed {
if (!textField.text.length) {
return;
}
}
- (void)viewDidAppear:(BOOL)animated {
[super viewDidAppear:animated];
[UIView animateWithDuration:0.3 animations:^{
self.view.backgroundColor = [UIColor colorWithWhite:0 alpha:0.7];
} completion:^(BOOL finished) {
}];
}
- (void)closeButtonPressed {
[UIView animateWithDuration:0.3 animations:^{
self.view.alpha = 0;
} completion:^(BOOL finished) {
[self.view removeFromSuperview];
[self removeFromParentViewController];
}];
}
- (void)setCompletionBlock:(void (^)(NSDictionary *, BOOL))block {
... ...
... ... @@ -7,6 +7,8 @@
//
#import <UIKit/UIKit.h>
#import "YH_RoomSecretViewController.h"
#import "YH_EndViewController.h"
@interface YH_RootViewController : UIViewController
... ...
... ... @@ -653,12 +653,15 @@
- (void)torchPressed:(UIButton *)sender {
if (_livePush.frontCamera) {//前置摄像头的AVcapturesession会与后置摄像头的闪光灯冲突,所以前置摄像头的情况下不允许开启闪光灯。
[self toastTip:@"前置摄像头不存在闪光灯。"];
return;
}
[_livePush toggleTorch:!sender.selected];
sender.selected = !sender.selected;
[YH_EndViewController showInController:self secret:@"9527" completionBlock:^(NSDictionary *dic, BOOL success) {
}];
// if (_livePush.frontCamera) {//前置摄像头的AVcapturesession会与后置摄像头的闪光灯冲突,所以前置摄像头的情况下不允许开启闪光灯。
// [self toastTip:@"前置摄像头不存在闪光灯。"];
// return;
// }
// [_livePush toggleTorch:!sender.selected];
// sender.selected = !sender.selected;
}
- (void)liveButtonPressed:(UIButton *)sender {
... ...