最近一直在做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];
}
}