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

最近一直在做weex的iOS APP,發(fā)現(xiàn)了不少坑,weex自帶的model.toast可以模擬iOS的各種提示框信息,但是實際應(yīng)用中發(fā)現(xiàn)在網(wǎng)頁端顯示正常,但在模擬器和真機上無法顯示,找了很久也沒發(fā)現(xiàn)有用的信息(weex相關(guān)的資料實在是太少了!),無意中發(fā)現(xiàn)了一篇文件完美解決這個問題。
方法一:如果App沒有使用storyboard布局,可以刪除Main.storyboard
首先刪除Main.storyboard(有潔癖的肯定也會刪除Xcode自動創(chuàng)建的ViewController),記住是移到廢紙簍,而不是刪除索引
然后刪除Info.plist中的選項: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)容合作請聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時請結(jié)合常識與多方信息審慎甄別。
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點,簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

相關(guān)閱讀更多精彩內(nèi)容

友情鏈接更多精彩內(nèi)容