[問題] 傳出ViewController.view顯示不正常

作者: duckscorpion (歆)   2018-03-01 18:53:10
使用React-native導出原生GameVC的View給JS使用
GameVC已在StoryBroad上使用Autolayout排成滿版
但遇到問題是run了之後 有時候會跑版
不曉得是什麼地方有問題?
試過直接修改frame = Screem.bounds也無作用
下面是我的code
請大大幫忙解答
//RNTGameManager.m
@interface RNTGameManager : RCTViewManager
@end
@implementation RNTGameManager
RCT_EXPORT_MODULE()
GameVC *vc;
- (UIView *)view {
UIStoryboard *mystoryboard = [UIStoryboard storyboardWithName:@"Main"
bundle:nil];
vc = [mystoryboard instantiateViewControllerWithIdentifier:@"StartVC"];
return vc.view;
}
// GameView.js
import ...
class GameView extends React.Component {
render() {
return <RNTGame {...this.props} />;
}
}
...
var RNTGame = requireNativeComponent('RNTGame', GameView);
module.exports = GameView;
//App.js
import GameView from "./GameView"
import ...
export default class App extends React.Component {
render() {
return (
<GameView style={{ flex: 1}}/>
);
}
...
}
作者: powerwolf543 (NixonShin)   2018-03-05 00:49:00
你這樣每次拿的view會是不同instance

Links booklink

Contact Us: admin [ a t ] ucptt.com