Peterfei

上主是我的牧者,我实在一无所缺


  • 首页

  • 归档

  • 标签

mac 跳过App Store 更新系统

发表于 2015-12-15   |   分类于 mac   |  

sudo softwareupdate -i -a
应用它就可以跳过臃肿的app store 进行系统更新了。

ionic 手动清除页面缓存方法

发表于 2015-12-08   |   分类于 Ionic   |  

ionic手动清除页面方法:

1
2
3
4
$scope.$on("$ionicView.beforeEnter", function () {
$ionicHistory.clearCache();
$ionicHistory.clearHistory();
});

angular directive ng-click not work

发表于 2015-12-07   |  

###隔离事件
中午在项目里遇到angular directive 里加入click事件,不能正常工作,查询API后,基本可以通过angularjs 的隔离scope 完成,具体实现如下:

html

1
<mobi edit-click="selectMobiFlag(1)" item="item"></mobi>

html 端定义了mobi的指令, 具体点击事件方法如selectMobileFlat,

指令(Directive)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
.directive('mobi', function() {
return {
restrict: 'EA',
scope: {
'item':'=',
'editClick': '&'
},
template: '<div ng-click="toggleState(item)" >111</div>',
link: function($scope, element, attrs) {
$scope.toggleState = function(item){
console.log(item);
$scope.editClick(item);
};
}
};
})

指令里绑定了item,传入的是点击 HTML片段本身,在directive里渲染了template 模板,主要负责点击的声明,在隔离作用域里,应用editClick:"&" 和 $scope.toggleState 实现关联。

###最后
实现selectMobiFlag的具体实现:

1
2
3
4
$scope.selectMobiFlag = function(item) {
$scope.mobiFlag = item;
}

ionic jpush IOS 配置

发表于 2015-12-04   |   分类于 前端   |  

###添加 IOS 平台
$ ionic platform add ios

###安装插件
ionic plugin add https://github.com/DongHongfei/jpush-phonegap-plugin.git

###修改配置
修改: ionic_jpush\plugins\cn.jpush.phonegap.JPushPlugin\src\ios\PushConfig.plist 修改对应的APP_KEY和CHANNEL
确保有如下代码,不然后面 Xcode 运行会警告:

1
2
<key>APS_FOR_PRODUCTION</key>
<string>0</string>

###编译 IOS 项目
$ ionic build ios

###修改配置 IOS 项目
修改 AppDelegate.m

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
*/
//
// AppDelegate.m
// ionic_jpush
//
// Created by ___FULLUSERNAME___ on ___DATE___.
// Copyright ___ORGANIZATIONNAME___ ___YEAR___. All rights reserved.
//
#import "AppDelegate.h"
#import "MainViewController.h"
#import "APService.h"
#import "JPushPlugin.h" //viper
#import <Cordova/CDVPlugin.h>
@implementation AppDelegate
@synthesize window, viewController;
- (id)init
{
/** If you need to do any extra app-specific initialization, you can do it here
* -jm
**/
NSHTTPCookieStorage* cookieStorage = [NSHTTPCookieStorage sharedHTTPCookieStorage];
[cookieStorage setCookieAcceptPolicy:NSHTTPCookieAcceptPolicyAlways];
int cacheSizeMemory = 8 * 1024 * 1024; // 8MB
int cacheSizeDisk = 32 * 1024 * 1024; // 32MB
#if __has_feature(objc_arc)
NSURLCache* sharedCache = [[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"];
#else
NSURLCache* sharedCache = [[[NSURLCache alloc] initWithMemoryCapacity:cacheSizeMemory diskCapacity:cacheSizeDisk diskPath:@"nsurlcache"] autorelease];
#endif
[NSURLCache setSharedURLCache:sharedCache];
self = [super init];
return self;
}
#pragma mark UIApplicationDelegate implementation
/**
* This is main kick off after the app inits, the views and Settings are setup here. (preferred - iOS4 and up)
*/
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
CGRect screenBounds = [[UIScreen mainScreen] bounds];
#if __has_feature(objc_arc)
self.window = [[UIWindow alloc] initWithFrame:screenBounds];
#else
self.window = [[[UIWindow alloc] initWithFrame:screenBounds] autorelease];
#endif
self.window.autoresizesSubviews = YES;
#if __has_feature(objc_arc)
self.viewController = [[MainViewController alloc] init];
#else
self.viewController = [[[MainViewController alloc] init] autorelease];
#endif
// Set your app's start page by setting the <content src='foo.html' /> tag in config.xml.
// If necessary, uncomment the line below to override it.
// self.viewController.startPage = @"index.html";
// NOTE: To customize the view's frame size (which defaults to full screen), override
// [self.viewController viewWillAppear:] in your view controller.
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
// Required
#if __IPHONE_OS_VERSION_MAX_ALLOWED > __IPHONE_7_1
if ([[UIDevice currentDevice].systemVersion floatValue] >= 8.0) {
//可以添加自定义categories
[APService registerForRemoteNotificationTypes:(UIUserNotificationTypeBadge |
UIUserNotificationTypeSound |
UIUserNotificationTypeAlert)
categories:nil];
} else {
//categories 必须为nil
[APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
}
#else
//categories 必须为nil
[APService registerForRemoteNotificationTypes:(UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound |
UIRemoteNotificationTypeAlert)
categories:nil];
#endif
// Required
[APService setupWithOption:launchOptions];
return YES;
}
// this happens while we are running ( in the background, or from within our own app )
// only valid if ionic_jpush-Info.plist specifies a protocol to handle
- (BOOL)application:(UIApplication*)application openURL:(NSURL*)url sourceApplication:(NSString*)sourceApplication annotation:(id)annotation
{
if (!url) {
return NO;
}
// all plugins will get the notification, and their handlers will be called
[[NSNotificationCenter defaultCenter] postNotification:[NSNotification notificationWithName:CDVPluginHandleOpenURLNotification object:url]];
return YES;
}
// repost all remote and local notification using the default NSNotificationCenter so multiple plugins may respond
- (void) application:(UIApplication*)application
didReceiveLocalNotification:(UILocalNotification*)notification
{
// re-post ( broadcast )
[[NSNotificationCenter defaultCenter] postNotificationName:CDVLocalNotification object:notification];
}
#ifndef DISABLE_PUSH_NOTIFICATIONS
- (void) application:(UIApplication*)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
// re-post ( broadcast )
NSString* token = [[[[deviceToken description]
stringByReplacingOccurrencesOfString:@"<" withString:@""]
stringByReplacingOccurrencesOfString:@">" withString:@""]
stringByReplacingOccurrencesOfString:@" " withString:@""];
[[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotification object:token];
// Required
[APService registerDeviceToken:deviceToken];
[APService setDebugMode];
}
- (void) application:(UIApplication*)application
didFailToRegisterForRemoteNotificationsWithError:(NSError*)error
{
// re-post ( broadcast )
[[NSNotificationCenter defaultCenter] postNotificationName:CDVRemoteNotificationError object:error];
}
#endif
- (NSUInteger)application:(UIApplication*)application supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
// iPhone doesn't support upside down by default, while the iPad does. Override to allow all orientations always, and let the root view controller decide what's allowed (the supported orientations mask gets intersected).
NSUInteger supportedInterfaceOrientations = (1 << UIInterfaceOrientationPortrait) | (1 << UIInterfaceOrientationLandscapeLeft) | (1 << UIInterfaceOrientationLandscapeRight) | (1 << UIInterfaceOrientationPortraitUpsideDown);
return supportedInterfaceOrientations;
}
- (void)applicationDidReceiveMemoryWarning:(UIApplication*)application
{
[[NSURLCache sharedURLCache] removeAllCachedResponses];
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// Required
[APService handleRemoteNotification:userInfo];
BOOL isActive;
if (application.applicationState == UIApplicationStateActive) {
isActive = TRUE;
} else {
isActive = FALSE;
}
NSDictionary *dict=[[NSMutableDictionary alloc] initWithDictionary:userInfo];
[dict setValue: [[NSNumber alloc] initWithBool:isActive] forKey:@"isActive" ];
[[NSNotificationCenter defaultCenter] postNotificationName:kJPushPluginReceiveNotification
object:dict] ;//viper
}
@end

Ionic ActionSheet Android 样式

发表于 2015-11-16   |   分类于 前端   |  

###Ionic ActionSheet Android 样式
在style.css拷贝如下样式表:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
/**
* Action Sheets for Android
* --------------------------------------------------
*/
.platform-android .action-sheet-backdrop {
-webkit-transition: background-color 150ms ease-in-out;
transition: background-color 150ms ease-in-out;
position: fixed;
top: 0;
left: 0;
z-index: 11;
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0);
}
.platform-android .action-sheet-backdrop.active {
background-color: rgba(0, 0, 0, 0.4);
}
.platform-android .action-sheet-wrapper {
-webkit-transform: translate3d(0, 100%, 0);
transform: translate3d(0, 100%, 0);
-webkit-transition: all cubic-bezier(0.36, 0.66, 0.04, 1) 500ms;
transition: all cubic-bezier(0.36, 0.66, 0.04, 1) 500ms;
position: absolute;
bottom: 0;
left: 0;
right: 0;
width: 100%;
max-width: 500px;
margin: auto;
}
.platform-android .action-sheet-up {
-webkit-transform: translate3d(0, 0, 0);
transform: translate3d(0, 0, 0);
}
.platform-android .action-sheet {
margin-left: 8px;
margin-right: 8px;
width: auto;
z-index: 11;
overflow: hidden;
}
.platform-android .action-sheet .button {
display: block;
padding: 1px;
width: 100%;
border-radius: 0;
border-color: #d1d3d6;
background-color: transparent;
color: #007aff;
font-size: 21px;
}
.platform-android .action-sheet .button:hover {
color: #007aff;
}
.platform-android .action-sheet .button.destructive {
color: #ff3b30;
}
.platform-android .action-sheet .button.destructive:hover {
color: #ff3b30;
}
.platform-android .action-sheet .button.active, .platform-android .action-sheet .button.activated {
box-shadow: none;
border-color: #d1d3d6;
color: #007aff;
background: #e4e5e7;
}
.platform-android .action-sheet-has-icons .icon {
position: absolute;
left: 16px;
}
.platform-android .action-sheet-title {
padding: 16px;
color: #8f8f8f;
text-align: center;
font-size: 13px;
}
.platform-android .action-sheet-group {
margin-bottom: 8px;
border-radius: 4px;
background-color: #fff;
overflow: hidden;
}
.platform-android .action-sheet-group .button {
border-width: 1px 0px 0px 0px;
}
.platform-android .action-sheet-group .button:first-child:last-child {
border-width: 0;
}
.platform-android .action-sheet-options {
background: #f1f2f3;
}
.platform-android .action-sheet-cancel .button {
font-weight: 500;
}
.platform-android .action-sheet-open {
pointer-events: none;
}
.platform-android .action-sheet-open.modal-open .modal {
pointer-events: none;
}
.platform-android .action-sheet-open .action-sheet-backdrop {
pointer-events: auto;
}
.platform-android .action-sheet .action-sheet-title, .platform-android .action-sheet .button {
text-align: center;
}
.platform-android .action-sheet-cancel {
display: block;
}

在android 下样式可以正常运行。

1…8910…16
peterfei

peterfei

peterfei|技术|上主是我的牧者

77 日志
14 分类
62 标签
RSS
github
© 2023 peterfei
由 Hexo 强力驱动
主题 - NexT.Mist