josh
josh

Reputation: 1689

Adding view onto Window of Twitter

Hi i am facing a strange problem. I have a class which is NSObject type, and on same class i want to share image on Facebook and Email and also on Twitter. I successfully done FB and Email, On Email i use [[[UIApplication sharedApplication] keyWindow] addSubview:mailer.view]; to show Mail controller onto Window instread of Presenting Model view controller and same as on Dismiss i use Remove from super view. But when i do same with twitter controller then twitter controller just show me few mili seconds and then hide. I also add new View controller onto Window and then Present its controller onto that View controller but same output. Don't know what going wrong. Please help on that. Thanks in advance. This will be great for me :)

Edited

 if (_engine != nil) {
    _engine = nil;
    [_engine release];
}    
_engine = [[SA_OAuthTwitterEngine alloc] initOAuthWithDelegate: self];
_engine.consumerKey = kOAuthConsumerKey;
_engine.consumerSecret = kOAuthConsumerSecret;

UIViewController *controller = [SA_OAuthTwitterController controllerToEnterCredentialsWithTwitterEngine:_engine delegate: self];

if (controller) {
    NSLog(@"Sharing on Twitter on loading controller of twitter");
     [[UIApplication sharedApplication].keyWindow addSubview:controller.view];

}
else {
    NSLog(@"Sharing on Twitter in else condition");
    [self sharetoTwitter:screenImg];
} 

ShareToTwitterMethod

- (void) sharetoTwitter:(UIImage *)img {
NSString *response = [_engine _uploadImage:img requestType:MGTwitterPublicTimelineRequest responseType:MGTwitterStatus]; 
NSLog(@"twitter post notification");
}

I used Add subview to load view instead of Presenting View.

Upvotes: 1

Views: 108

Answers (1)

Sumanth
Sumanth

Reputation: 4921

Have you tried this

UIWindow *window = [[UIApplication sharedApplication] keyWindow];
[window addSubView:controller.view];
[window makeKeyAndVisible];//important line dont forget to set this line

Upvotes: 1

Related Questions