0
我使用Outh將Twitter添加到我的應用程序。無法發佈來自另一個ViewController的推文
下面是分別用於登錄和發佈推文的兩個UIViewController。
1.SettingViewcontroller 2.DetailViewcontroller
此代碼爲登錄與SettingViewcontroller嘰嘰喳喳。
- (void)switchAction1:(UISwitch*)sender
{
if (sender.on)
{
if(_engine)
return;
_engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self]
_engine.consumerKey = @"###";
_engine.consumerSecret = @"###";
UIViewController *controller =[SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine: _engine delegate: self];
DetailViewcontroller *detobj=[[DetailViewcontroller alloc]init];
detobj.detail_enginne=_engine;
[detobj release];
[self presentModalViewController: controller animated: YES];
}
if(!sender.on)
{
NSLog(@"Logout section");
}
}
而在詳細查看控制器動作表按鈕cliked時下面的代碼會執行。
if ([detail_enginne isAuthorized])
{
NSLog(@"engine availble");
NSString *[email protected]"hai twitterrrrrrrrrrr";
[detail_enginne sendUpdate:str];
}
else{
NSLog(@"Engine not availabele");
}
}
這裏Iam無法發送來自DetailViewcontroller的推文。
如何實現這個?
更新使用viewDidLoad中不筆尖
蔭裝載儀詳細視圖。
Detailview.m
這是從的DetailView數據發佈到Facebook和Twitter
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex {
// For facebook
if(buttonIndex == 0)
{
if ([session resume]) {
[self postToWall];
NSLog(@"Post to wall");
}
else {
self.loginDialog = nil;
_loginDialog = [[FBLoginDialog alloc] init];
[_loginDialog show];
}
}
// For twittter
if(buttonIndex == 1)
{
if(detail_enginne!=nil)
{
NSString *[email protected]" hai twitter ";
[detail_enginne sendUpdate:str];
}
else
{
NSLog(@"Not availabele");
}
}
if(buttonIndex == 2)
{
NSLog(@"cancel button ");
}
}
我有動作片按鈕,在Detailviewcontroller.When用戶點擊按鈕TIS數據名爲「推特」應該有post.I嘗試ur代碼,但不working.U請chek我的問題,我已更新。謝謝 –
當switch.on是真的。在獲取登錄憑證和獲取憑證之前。如果在獲取憑證後,註釋行, –
_engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate:self] _engine.consumerKey = @「###」; _engine.consumerSecret = @「###」; UIViewController * controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate:self]; –