我使用TwitterKit发送推文,使用此代码。
--------+-------+--+
| contar | final | |
+--------+-------+--+
| 1 | -4 | |
| 2 | -3 | |
| 5 | 0 | |
| 1 | -4 | |
+--------+-------+--+
但代码崩溃
TWTRComposer *twitterComposer = [[TWTRComposer alloc] init];
[twitterComposer setText:string];
[twitterComposer setURL:[NSURL URLWithString:url]];
[twitterComposer setImage:image];
[twitterComposer showFromViewController:viewController completion:^(TWTRComposerResult result) {
if (result == TWTRComposerResultDone) {
}else {
}
}];
我获得了Twitter登录会话
使用SLComposerViewController崩溃
崩溃信息: 应用程序尝试在目标<>
上显示nil模态视图控制器 10.0.2中的中找不到任何答案
答案 0 :(得分:2)
在调用TWTRComposer之前检查会话。否则应用程序将崩溃。 试试这个:
[[Twitter sharedInstance] logInWithCompletion:^(TWTRSession * _Nullable session, NSError * _Nullable error) {
if (session) {
TWTRComposer *composer = [[TWTRComposer alloc] init];
[composer setText:@"just setting up my Fabric"];
[composer setImage:[UIImage imageNamed:@"fabric"]];
[composer setURL:[NSURL URLWithString:@"http://www.toshow.com"]];
[composer showFromViewController:[UIApplication sharedApplication].keyWindow.rootViewController completion:^(TWTRComposerResult result) {
}];
} else {
[CustomToast makeToast:@"get session failed"];
}
}];