主播卡片弹出时手机震动
This commit is contained in:
@@ -64,8 +64,8 @@
|
||||
|
||||
- (void)removeFromSuperview {
|
||||
[super removeFromSuperview];
|
||||
[self resumeTimer];
|
||||
if (self.isPlaying) {
|
||||
[self resumeTimer];
|
||||
[[XPSkillCardPlayerManager shareInstance] stopMusic];
|
||||
}
|
||||
}
|
||||
|
@@ -10,6 +10,7 @@
|
||||
#import <ReactiveObjC/ReactiveObjC.h>
|
||||
#import <NIMSDK/NIMSDK.h>
|
||||
#import <Masonry/Masonry.h>
|
||||
#import <AudioToolbox/AudioToolbox.h>
|
||||
///Tool
|
||||
#import "XPMacro.h"
|
||||
#import "ThemeColor.h"
|
||||
@@ -141,7 +142,7 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
vc.hadAnimate = YES;
|
||||
[self.selectedViewController.navigationController presentViewController:vc animated:YES completion:nil];
|
||||
}
|
||||
if ([self hadLaunchApp] && (self.selectedIndex == 0 | self.selectedIndex == 1) && [self canShowAnchorCard]) {
|
||||
if ([self hadLaunchApp] && [self canShowAnchorCard]) {
|
||||
dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(5 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{
|
||||
if (self.view.window && self.isViewLoaded) {
|
||||
[self.presenter getAnchorCardInfo];
|
||||
@@ -258,11 +259,8 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
self.anchorCardView.frame = CGRectMake(0, -90-kStatusBarHeight, KScreenWidth, 90);
|
||||
[UIView animateWithDuration:0.5 animations:^{
|
||||
self.anchorCardView.frame = CGRectMake(0, kStatusBarHeight, KScreenWidth, 90);
|
||||
} completion:^(BOOL finished) {
|
||||
if (finished) {
|
||||
[self shakeAction];
|
||||
}
|
||||
}];
|
||||
} completion:nil];
|
||||
AudioServicesPlaySystemSound(kSystemSoundID_Vibrate);//默认震动效果
|
||||
long time = (long)([[NSDate date] timeIntervalSince1970]*1000);
|
||||
[[NSUserDefaults standardUserDefaults] setObject:@(time) forKey:kLastShowAnchorCardTime];
|
||||
[[NSUserDefaults standardUserDefaults] synchronize];
|
||||
@@ -274,36 +272,6 @@ UIKIT_EXTERN NSString *kTabShowAnchorCardKey;
|
||||
}
|
||||
}
|
||||
|
||||
///主播卡片震动动画
|
||||
- (void)shakeAction {
|
||||
// 晃动次数
|
||||
static int numberOfShakes = 4;
|
||||
// 晃动幅度(相对于总宽度)
|
||||
static float vigourOfShake = 0.04f;
|
||||
// 晃动延续时常(秒)
|
||||
static float durationOfShake = 0.5f;
|
||||
CAKeyframeAnimation *shakeAnimation = [CAKeyframeAnimation animationWithKeyPath:@"position"];
|
||||
//关键帧(点)
|
||||
CGPoint layerPosition = self.anchorCardView.layer.position;
|
||||
// 起始点
|
||||
NSValue *value1 = [NSValue valueWithCGPoint:self.anchorCardView.layer.position];
|
||||
// 关键点数组
|
||||
NSMutableArray *values = [[NSMutableArray alloc] initWithObjects:value1, nil];
|
||||
for (int i = 0; i<numberOfShakes; i++) {
|
||||
// 左右晃动的点
|
||||
NSValue *valueLeft = [NSValue valueWithCGPoint:CGPointMake(layerPosition.x-self.anchorCardView.frame.size.width*vigourOfShake*(1-(float)i/numberOfShakes), layerPosition.y)];
|
||||
NSValue *valueRight = [NSValue valueWithCGPoint:CGPointMake(layerPosition.x+self.anchorCardView.frame.size.width*vigourOfShake*(1-(float)i/numberOfShakes), layerPosition.y)];
|
||||
|
||||
[values addObject:valueLeft];
|
||||
[values addObject:valueRight];
|
||||
}
|
||||
// 最后回归到起始点
|
||||
[values addObject:value1];
|
||||
shakeAnimation.values = values;
|
||||
shakeAnimation.duration = durationOfShake;
|
||||
[self.anchorCardView.layer addAnimation:shakeAnimation forKey:kCATransition];
|
||||
}
|
||||
|
||||
#pragma mark - NIMLoginManagerDelegate
|
||||
- (void)onAutoLoginFailed:(NSError *)error {
|
||||
// 如果非上次登录设备 autoLogin 会返回 417
|
||||
|
@@ -20,6 +20,10 @@
|
||||
#import "XCCurrentVCStackManager.h"
|
||||
#import "XPMineUserInfoViewController.h"
|
||||
#import "XPMineRechargeViewController.h"
|
||||
///vc
|
||||
#import "XPMineDressUpViewController.h"
|
||||
#import "XPDressUpShopViewController.h"
|
||||
#import "XPRoomViewController.h"
|
||||
|
||||
typedef NS_ENUM(NSUInteger, RightNavigationPushType){
|
||||
///跳转h5页面
|
||||
@@ -83,6 +87,8 @@ NSString * const kJSGetRoomUid = @"getRoomUid";
|
||||
NSString * const kOpenPersonPage = @"openPersonPage";
|
||||
NSString * const kInitShowNav = @"initShowNav";
|
||||
NSString * const kCloseWebView = @"closeWebView";
|
||||
NSString * const kJumpAppointPage = @"jumpAppointPage";
|
||||
NSString * const kJSOpenRoom = @"openRoom";
|
||||
|
||||
@implementation XPWebViewController
|
||||
|
||||
@@ -262,11 +268,124 @@ NSString * const kCloseWebView = @"closeWebView";
|
||||
if (self.navigationController) {
|
||||
[self.navigationController popViewControllerAnimated:YES];
|
||||
}
|
||||
}
|
||||
} else if ([message.name isEqualToString:kJumpAppointPage]) {
|
||||
// h5与原生交互新协议
|
||||
NSDictionary *bodyDict;
|
||||
if ([message.body isKindOfClass:[NSDictionary class]]) {
|
||||
bodyDict = message.body;
|
||||
} else if ([message.body isKindOfClass:[NSString class]]) {
|
||||
NSString *str = (NSString *)message.body;
|
||||
bodyDict = [str toJSONObject];
|
||||
}
|
||||
NSInteger skyType = [bodyDict[@"routerType"] integerValue];
|
||||
[self handleRouterType:skyType message:message];
|
||||
} else if ([message.name isEqualToString:kJSOpenRoom]) {
|
||||
// NSDictionary *bodyDict;
|
||||
// if ([message.body isKindOfClass:[NSDictionary class]]) {
|
||||
// bodyDict = message.body;
|
||||
// } else if ([message.body isKindOfClass:[NSString class]]) {
|
||||
// NSString *str = (NSString *)message.body;
|
||||
// bodyDict = [str toJSONObject];
|
||||
// }
|
||||
NSString *uid = [NSString stringWithFormat:@"%@",message.body];
|
||||
if (uid.length > 0) {
|
||||
[XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||
}
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
|
||||
#pragma mark - private method
|
||||
- (void)handleRouterType:(NSInteger)skyType message:(WKScriptMessage *)message {
|
||||
NSDictionary *bodyDict = (NSDictionary *)message.body;
|
||||
switch (skyType) {
|
||||
case 1:
|
||||
{
|
||||
//房间页 传参:uid
|
||||
NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]];
|
||||
if (uid.length) {
|
||||
[XPRoomViewController openRoom:uid viewController:[XCCurrentVCStackManager shareManager].getCurrentVC];
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case P2PInteractive_SkipType_H5:
|
||||
// {
|
||||
// //H5
|
||||
// NSString *urlString = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]];
|
||||
// if (urlString.length) {
|
||||
// XCWKWebViewController *vc = [[[self class] alloc] init];
|
||||
// vc.urlString = urlString;
|
||||
// [self.navigationController pushViewController:vc animated:YES];
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
// case P2PInteractive_SkipType_Purse:
|
||||
// {
|
||||
// //钱包页
|
||||
// [self h5OpenPurseAction:message];
|
||||
// }
|
||||
// break;
|
||||
// case P2PInteractive_SkipType_Recharge:
|
||||
// {
|
||||
// //充值页
|
||||
// [self h5OpenChargePageAction:message];
|
||||
// }
|
||||
// break;
|
||||
// case P2PInteractive_SkipType_Person:
|
||||
// {
|
||||
// //个人页 传参:uid
|
||||
// NSString *uid = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]];
|
||||
// if (uid.length) {
|
||||
// [self h5OpenPersonPageAction:uid.userIDValue message:message];
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
case 7:
|
||||
{
|
||||
//座驾
|
||||
XPMineDressUpViewController *vc = [[XPMineDressUpViewController alloc] init];
|
||||
vc.currentIndex = 1;
|
||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
case 8:
|
||||
{
|
||||
//头饰
|
||||
XPMineDressUpViewController *vc = [[XPMineDressUpViewController alloc] init];
|
||||
vc.currentIndex = 0;
|
||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
// case P2PInteractive_SkipType_SystemMessage:
|
||||
// {
|
||||
// //系统消息
|
||||
// [self h5JumpSystemMessageAction:message];
|
||||
// }
|
||||
// break;
|
||||
case 73:
|
||||
{
|
||||
//装扮商城
|
||||
NSString *index = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]];
|
||||
XPDressUpShopViewController *vc = [[XPDressUpShopViewController alloc] init];
|
||||
vc.currentIndex = [index integerValue];
|
||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
case 74:
|
||||
{
|
||||
//我的装扮
|
||||
NSString *index = [NSString stringWithFormat:@"%@", bodyDict[@"routerVal"]];
|
||||
XPMineDressUpViewController *vc = [[XPMineDressUpViewController alloc] init];
|
||||
vc.currentIndex = [index integerValue];
|
||||
[[XCCurrentVCStackManager shareManager].getCurrentVC.navigationController pushViewController:vc animated:YES];
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
- (void)setUrl:(NSString *)urlString{
|
||||
_url = urlString;
|
||||
if (_url == nil) {
|
||||
@@ -517,7 +636,10 @@ NSString * const kCloseWebView = @"closeWebView";
|
||||
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kInitShowNav];
|
||||
// 隐藏导航栏
|
||||
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kCloseWebView];
|
||||
|
||||
//装扮及其他活动页面
|
||||
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJumpAppointPage];
|
||||
//进入房间
|
||||
[_userContentController addScriptMessageHandler:weakScriptMessageDelegate name:kJSOpenRoom];
|
||||
}
|
||||
return _userContentController;
|
||||
}
|
||||
|
Reference in New Issue
Block a user