You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@weex.apache.org by emptywalker <gi...@git.apache.org> on 2018/02/28 06:25:18 UTC
[GitHub] incubator-weex pull request #1043: [iOS] bugfix toast not displayed
GitHub user emptywalker opened a pull request:
https://github.com/apache/incubator-weex/pull/1043
[iOS] bugfix toast not displayed
Toast cannot be displayed in your project, but can be displayed in the playground. My environment is as follows:
```
weexSDK: 0.18.0
$ weex -v
v1.1.0-beta.7
- weexpack : v0.4.7-beta.26
- weex-builder : v0.2.13-beta.4
- weex-devtool : v0.3.2-beta.11
- weex-previewer : v1.3.13-beta.10
```
The vue code is as follows:
```
<template>
<div>
<text @click="clicked(0)">点我有弹框</text>
</div>
</template>
<script>
const { toast } = require('./util.js');
const navigator = weex.requireModule('navigator');
export default {
methods: {
cellClicked() {
const modal = weex.requireModule('modal');
modal.toast({
message: '123120----3123',
duration: 1,
});
}
}
}
</script>
```
According to issue [#2183](https://github.com/alibaba/weex/issues/2183), the following solution is found:
```
- (void)toast:(NSString *)message duration:(double)duration
{
WXAssertMainThread();
// UIView *superView = [[[UIApplication sharedApplication] windows] objectAtIndex:0];
// 将上行的代码该为下行就好了。
UIView *superView = [[[UIApplication sharedApplication] windows] lastObject];
if (!superView) {
superView = self.weexInstance.rootView;
}
UIView *toastView = [self toastViewForMessage:message superView:superView];
WXToastInfo *info = [WXToastInfo new];
info.toastView = toastView;
info.superView = superView;
info.duration = duration;
[[WXToastManager sharedManager].toastQueue addObject:info];
if (![WXToastManager sharedManager].toastingView) {
[self showToast:toastView superView:superView duration:duration];
}
}
```
With the help of @acton393, I identified the problem by comparing two applications of Windows.
playground:
```
(lldb) po [[UIApplication sharedApplication] windows]
<__NSArrayM 0x600000057430>(
<UIWindow: 0x7fa239f00970; frame = (0 0; 414 736); gestureRecognizers = <NSArray: 0x60c000049540>; layer = <UIWindowLayer: 0x60c000033640>>,
<WXWindow: 0x7fa239e06580; baseClass = UIWindow; frame = (110 0; 60 40); gestureRecognizers = <NSArray: 0x60400025a940>; layer = <UIWindowLayer: 0x604000222320>>,
<ATBaseWindow: 0x7fa239e03a30; baseClass = UIWindow; frame = (0 0; 414 736); gestureRecognizers = <NSArray: 0x60c000049780>; layer = <UIWindowLayer: 0x60c0000338e0>>
)
```
my APP:
```
(lldb) po [[UIApplication sharedApplication] windows]
<__NSArrayM 0x608000252e10>(
<UIWindow: 0x7fe9dc106b50; frame = (0 0; 375 812); hidden = YES; gestureRecognizers = <NSArray: 0x6080002510d0>; layer = <UIWindowLayer: 0x60800003e2c0>>,
<UIWindow: 0x7fe9dc10db10; frame = (0 0; 375 812); gestureRecognizers = <NSArray: 0x608000251970>; layer = <UIWindowLayer: 0x608000222020>>
)
```
**reason**
The first window in my project was hidden, so toast couldn't find super view.
**solution**
`UIView *superView = [[[UIApplication sharedApplication] windows] objectAtIndex:0];` -> `UIView *superView = [[UIApplication sharedApplication] keyWindow];`
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/emptywalker/incubator-weex master
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/incubator-weex/pull/1043.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #1043
----
commit dd9bf77d17e8fc140298e3e8c65ddbd7a87833e3
Author: emptywalker <em...@...>
Date: 2018-02-28T06:06:30Z
[iOS]bugfix toast not displayed
----
---
[GitHub] incubator-weex pull request #1043: * [iOS] bugfix toast not displayed
Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:
https://github.com/apache/incubator-weex/pull/1043
---
[GitHub] incubator-weex issue #1043: * [iOS] bugfix toast not displayed
Posted by weex-bot <gi...@git.apache.org>.
Github user weex-bot commented on the issue:
https://github.com/apache/incubator-weex/pull/1043
<!--
0 failure:
0 warning:
2 messages
-->
<table>
<thead>
<tr>
<th width="50"></th>
<th width="100%" data-danger-table="true">Messages</th>
</tr>
</thead>
<tbody><tr>
<td>:book:</td>
<td>has no jsfm file changed.</td>
</tr>
<tr>
<td>:book:</td>
<td>jsfm test finished.</td>
</tr>
</tbody>
</table>
<p align="right">
Generated by :no_entry_sign: <a href="http://github.com/danger/danger-js/">dangerJS</a>
</p>
---