Submitted by gouki on 2017, January 27, 12:03 AM
When I tried to build and run, Xcode said my device was locked. I looked at my iPhone, and it's not locked at all....possible bug? How do I fix this?
1.Did you by chance not "trust" the device? This will prevent it from communicating with xcode even if the device is unlocked.
2.Unplug the device, close xcode, and then open xcode and plugin the device. When you plug it in (after unlocking it) it you should be prompted to "trust" the computer (in the iOS device). My guess is you may have accidentally tapped "do not trust" and so the device will refuse to connect to the computer.
3.Lock the device,Remove cable from device.,Unlock the device,Connect again to Mac
苹果相关 | 评论:0
| 阅读:16458
Submitted by gouki on 2017, January 25, 10:07 PM
nestable在点击的时候,有一个拖动的状态被触发,会导致你给nestable上加的链接都会无效。
只要在最外层的li里加入一个class为:dd-nodrag,就不会被触发了。然后你在子菜单中就可以为它们加入工具菜单了,比如编辑 、删除等。
又或者,你加入dd-handle,这样的话,只能点击最左侧的handle部位才能被拖动
参考 :http://dbushell.github.io/Nestable/ 最下面
Javascript | 评论:0
| 阅读:20386
Submitted by gouki on 2017, January 18, 9:48 AM
一个很简单的laravel代码:
PHP代码
- User::where('id',1)->update(['last_login'=>time()]);
这样一个简单的代码,你会发现,它并没有触发:updating,updated事件,然而,你又会发现,updated_at也更新了。这是怎么回事?
跟进代码看一下,你会发现这个update,是Eloquent\Builder的方法,它的update方法代码很简单:
PHP代码
-
-
-
-
-
-
- public function update(array $values)
- {
- return $this->toBase()->update($this->addUpdatedAtColumn($values));
- }
我擦 ,要不要这么直接?再看一下toBase,这回是调用的是Query\Builder了。这里的update,就纯粹是生成sql,然后execute,不再走EloquentORM的事件了,所以就不会触发任何事件。
那么要怎么样才能触发事件呢?方法有两种
1、不要这样简写:先读数据再update,就一定会触发
2、不要用where(),而是直接User::find(1)->update([]),这时候就会从ORM走了。
这事儿官方有解释:
https://laravel.com/docs/5.3/eloquent#updates
- When issuing a mass update via Eloquent, the saved and updated model events will not be fired for the updated models. This is because the models are never actually retrieved when issuing a mass update.
同时,这事儿在stackoverflow上也有很多人在问,有人回复的就是和我上面的一样:
http://stackoverflow.com/questions/41295032/laravel-eloquent-model-update-event-is-not-fired
- You need to retrieve the user from the database and then save that user in order to fire the event. For example:
-
- This will NOT fire the update event:
-
- User::where('id', $id)->update(['username' => $newUsername]);
- This will fire the update event:
-
- User::find($id)->update(['username' => $newUsername]);
官方的解释我是看过了,下面的是我用了很多办法没法解决后才找到的。
我在想,use SoftDeletes可以注入代码,为什么我不行?直到我发现softdeletes是官方自带库,人家都准备了事件:onDelete了。。怎么就没有onUpdate事件可以让我加点字段呢?
然后我又想用其他的Scope,也没有成功(折腾了一个下午)
暂时放弃!就这样吧,不过我还在想想,有没有什么办法可以注入,因为在sql生成完后,它还是有触发的事件的,比如:
PHP代码
-
-
-
-
-
-
-
-
- public function logQuery($query, $bindings, $time = null)
- {
- if (isset($this->events)) {
- $this->events->fire(new Events\QueryExecuted(
- $query, $bindings, $time, $this
- ));
- }
-
- if ($this->loggingQueries) {
- $this->queryLog[] = compact('query', 'bindings', 'time');
- }
- }
-
- /**
- * Register a database query listener with the connection.
- *
- * @param \Closure $callback
- * @return void
- */
- public function listen(Closure $callback)
- {
- if (isset($this->events)) {
- $this->events->listen(Events\QueryExecuted::class, $callback);
- }
- }
-
- /**
- * Fire an event for this connection.
- *
- * @param string $event
- * @return void
- */
- protected function fireConnectionEvent($event)
- {
- if (! isset($this->events)) {
- return;
- }
-
- switch ($event) {
- case 'beganTransaction':
- return $this->events->fire(new Events\TransactionBeginning($this));
- case 'committed':
- return $this->events->fire(new Events\TransactionCommitted($this));
- case 'rollingBack':
- return $this->events->fire(new Events\TransactionRolledBack($this));
- }
- }
实在不行了,还可以在事务上面想想办法,但是总归是只能一次处理,如果是需要两次执行sql。那还不如直接写代码呢。等有空再看了
PHP | 评论:0
| 阅读:15216
Submitted by gouki on 2017, January 14, 9:41 AM
记录一下,真机编译的时候没问题,用模拟器的时候报:INSTALL_FAILED_NO_MATCHING_ABIS,查了一下原因。就是因为为了提速用了、x86的模拟,所以。。。
还好stackoverflow有人解决了这些问题:
1、http://stackoverflow.com/questions/24572052/install-failed-no-matching-abis-when-install-apk
2、http://stackoverflow.com/questions/24751350/install-failed-no-matching-abis-how-to-overcome
解决起来还是比较简单的,在app/build.grade的android节点下增加:
XML/HTML代码
- abi {
- enable true
- reset()
- include 'x86', 'armeabi-v7a'
- universalApk true
- }
- }
一切就OK了,再编译的时候就:
XML/HTML代码
- 01/14 09:36:59: Launching app
- $ adb install-multiple -r /xxxxx/app/build/outputs/apk/app-x86-debug.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_5.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_6.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_9.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_2.apk /xxxxx/app/build/intermediates/split-apk/debug/dep/dependencies.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_8.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_7.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_3.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_4.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_0.apk /xxxxx/app/build/intermediates/split-apk/debug/slices/slice_1.apk
- Split APKs installed
- $ adb shell am start -n "com.xxxxx.app/com.xxxxx.app.activity.StartActivity" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
- $ adb shell am startservice com.xxxxxx.app/com.android.tools.fd.runtime.InstantRunService
- Connected to process 3689 on device emulator-5554
居然切成了10个apk.....
Misc | 评论:0
| 阅读:24960
Submitted by gouki on 2017, January 5, 1:54 PM
这个标题可不是标题党,主要是我的macbook已经开启了双重认证,即我在任何一台设备上登录我的appleid,都会在手机上弹出:是否允许登录。然后输入系统给我的安全码,输进去就OK了。
然而问题发生在yosemate上,我登录apple store,结果没有弹出任何窗口来让我输入安全码。这怎么破?开始的时候一直无解。我以为把密码改成安全码就行了,然而直接告诉我密码错误。然后我又去官网后台生成一个所谓的专用密码来登录,也是告诉我密码错误。。。崩溃 !
最后google了一下,原来在官网上还真有介绍 :
https://support.apple.com/zh-cn/HT204915
- 如果我在运行旧版软件的设备上使用双重认证,会怎样?
- 如果您在运行旧版操作系统的设备上使用双重认证,系统可能会要求您在登录时将六位验证码添加至密码末尾。从运行 iOS 9 及更高版本或 OS X El Capitan 及更高版本的受信任设备中获取验证码,或者将其发送至受信任的电话号码。然后直接在密码栏位中键入密码,后跟六位验证码。
于是我登录apple store时,先输入密码,点击登录。然后在手机上弹出授权,点击允许,再将手机上的6位安全码,输到刚才 旧版机器 的密码框里(跟在最后),即:原密码+安全码,再点击登录。成功!
好吧。看起来不复杂,搞定就好
苹果相关 | 评论:0
| 阅读:18705