weex iOS中toast無法顯示的bug解決方案

最近一直在做weex的iOS APP,發(fā)現(xiàn)了不少坑,weex自帶的model.toast可以模擬iOS的各種提示框信息,但是實(shí)際應(yīng)用中發(fā)現(xiàn)在網(wǎng)頁端顯示正常,但在模擬器和真機(jī)上無法顯示,找了很久也沒發(fā)現(xiàn)有用的信息(weex相關(guān)的資料實(shí)在是太少了!),無意中發(fā)現(xiàn)了一篇文件完美解決這個(gè)問題。
方法一:如果App沒有使用storyboard布局,可以刪除Main.storyboard
首先刪除Main.storyboard(有潔癖的肯定也會(huì)刪除Xcode自動(dòng)創(chuàng)建的ViewController),記住是移到廢紙簍,而不是刪除索引
然后刪除Info.plist中的選項(xiàng):Main storyboard file base name即可

方法二:修改WXModalUIModule.m中的方法如下即可:

- (void)toast:(NSString *)message duration:(double)duration
{
    WXAssertMainThread();
    UIView *superView =  [[[UIApplication sharedApplication] windows] objectAtIndex:0];
    if (!superView || superView.hidden) {
        superView = [UIApplication sharedApplication].keyWindow;
    }
    if (!superView || superView.hidden) {
        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];
    }
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容