Can't add Twitter view to the scene - cocoa-touch

I am trying to add a Twitter view so I can see that it's being called, and also that the account is connected, but the Twitter sheet is not there ...
It's on a CCScene .(cocos2d)
if ([TWTweetComposeViewController canSendTweet])
{
//we can log here
TWTweetComposeViewController *tweetViewController = [[TWTweetComposeViewController alloc] init];
[tweetViewController setInitialText:#"message"];
tweetViewController.completionHandler = ^(TWTweetComposeViewControllerResult result)
{
if(result == TWTweetComposeViewControllerResultDone)
{
} else if(result == TWTweetComposeViewControllerResultCancelled)
{
}
[viewController dismissViewControllerAnimated:YES completion:nil];
};
// present view controller
[[[CCDirector sharedDirector] view] addSubview:viewController.view];
[viewController presentViewController:tweetViewController animated:YES completion:nil];
}
else
{
NSLog(#"NO TWITTER ");
}

[[CCDirector sharedDirector]presentModalViewController:tweetViewController animated:YES];
instead of the 2 lines that present the modal view .

Related

can't dismiss game center leaderboard

I have a app, and i'm using GameCenter leaderboard.
but i can't dismiss the leaderboard:
this is my code :
-(void)showLeaderboard {
GKGameCenterViewController *leaderboardController = [[GKGameCenterViewController alloc] init];
if (leaderboardController != NULL)
{
leaderboardController.leaderboardIdentifier = #"Leaderboard";
leaderboardController.viewState = GKGameCenterViewControllerStateLeaderboards;
leaderboardController.gameCenterDelegate = self;
UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: leaderboardController animated: YES completion:nil];
}
}
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)viewController
{
NSLog(#"Close");
UIViewController *vc = self.view.window.rootViewController;
[vc dismissViewControllerAnimated:YES completion:nil];
}
I have no idea what to do, :-
Try dismissing your viewController in the code
Change your code like this
-(void)showLeaderBoard
{
if (leaderboardController != NULL)
{
leaderboardController.leaderboardIdentifier = #"Leaderboard";
leaderboardController.viewState = GKGameCenterViewControllerStateLeaderboards;
leaderboardController.gameCenterDelegate = self;
[self presentViewController: leaderboardController animated: YES completion:nil];
}
}
- (void)gameCenterViewControllerDidFinish:(GKGameCenterViewController *)viewController
{
[viewController dismissViewControllerAnimated:YES completion:nil];
}

Heading UITableView issue in ios8

I am using splitviewcontroller into my app.depends on selection in master view.......deatil view will appear........we are having multiple detail view.
This my code to call the detail view
- (void)setDetailItem:(id)newDetailItem
{
[self.navigationController setDelegate:self];
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
}
if([[self.detailItem description] isEqualToString:#"Companies"])
{
listViewController_ = [self.storyboard instantiateViewControllerWithIdentifier:#"ListStoryBoard"];
[self addChildViewController:listViewController_];
if (![[PSAWebServices sharedInstance] isPushInProcess]) {
[self.navigationController pushViewController:listViewController_ animated:YES];
}
}
else if ([[self.detailItem description] isEqualToString:#"Contacts"])
{
contactlistViewController_ = [self.storyboard instantiateViewControllerWithIdentifier:#"contactListView"];
[self addChildViewController:contactlistViewController_];
if (![[PSAWebServices sharedInstance] isPushInProcess])
{
[self.navigationController pushViewController:contactlistViewController_ animated:YES];
}
}
else if ([[self.detailItem description] isEqualToString:#"Projects"])
{
projectViewController_ = [self.storyboard instantiateViewControllerWithIdentifier:#"projectListView"];
[self addChildViewController:projectViewController_];
if (![[PSAWebServices sharedInstance] isPushInProcess])
{
[self.navigationController pushViewController:projectViewController_ animated:YES];
}
}
else if ([[self.detailItem description] isEqualToString:#"Activities"])
{
activitiesViewController_ = [self.storyboard instantiateViewControllerWithIdentifier:#"activityListView"];
[self addChildViewController:activitiesViewController_];
if (![[PSAWebServices sharedInstance] isPushInProcess])
{
[self.navigationController pushViewController:activitiesViewController_ animated:YES];
}
}
else if ([[self.detailItem description] isEqualToString:#"Calendar"])
{
calendarViewController_ = [self.storyboard instantiateViewControllerWithIdentifier:#"CalendarStoryBoard"];
//[self.navigationController setNavigationBarHidden:YES];
[self addChildViewController:calendarViewController_];
//[self.view addSubview:self.calendarViewController.view];
//[self.navigationController pushViewController:calendarViewController_ animated:YES];
if (![[PSAWebServices sharedInstance] isPushInProcess])
{
[self.navigationController pushViewController:calendarViewController_ animated:YES];
}
}
}
here is problem which come only first time
My question is I am not able to set the frame of the detail view in ios8 with using the Auto layout and constraints
can u plz help me out this?
Thanks in advance
but i when rotated device it get fit correctly in screen
where i am getting wrong

ios7 - how to transition back to self

as per the following storyboard, I have a RootViewController (embedded in a TabBarController), which manage many ViewControllers with a vertical menu.
When this RootViewController did load, I check for client authentication, and if not yet authenticated, I switch to a ConnectViewController for remote authentication
#implementation WDURootViewController
....
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
if (!self.client.isAuthorized) {
WDUConnectViewController *cvc = self.connectVC;
[self addChildViewController:cvc];
[self.view addSubview:cvc.view];
[cvc didMoveToParentViewController:self];
}
}
when authentication is successful, I want to come back to the RootViewController...
so in my ConnectViewController, I call back a didConnect() method to notify the RootViewController
#implementation WDUConnectViewController
....
- (IBAction)sendGrantRequest
{
....
[self.client authorizeUser:login password:pwd
onSuccess:^() {
[self.workinOnIt stopAnimating];
[self.connectButton setEnabled:YES];
[(WDURootViewController *)self.parentViewController didConnect];
}
and in the RootViewController, didConnect() method I try to switch the views, in transition from the ConnectViewController to the RootViewController
#implementation WDURootViewController
....
- (void)didConnect
{
[self transitionFrom:self.connectVC To:self];
}
....
- (void)transitionFrom:(UIViewController *)oldC To:(UIViewController *)newC
{
[oldC willMoveToParentViewController:nil];
[self addChildViewController:newC];
[self transitionFromViewController: oldC toViewController: newC
duration: 0.25 options:0
animations: nil
completion:^(BOOL finished) {
[oldC removeFromParentViewController];
[newC didMoveToParentViewController:self];
}];
}
- (WDUConnectViewController *)connectVC {
if (_connectVC == nil) {
UIStoryboard *storyboard = self.storyboard;
_connectVC = [storyboard instantiateViewControllerWithIdentifier:#"WDUConnectViewController"];
_connectVC.client = self.client;
}
return _connectVC;
}
but the transition method is looping... I guess it's not the way to go , what's the simplest way?
I got it , just updating the didConnect() method in the RootViewController
- (void)didConnect
{
[self.connectVC willMoveToParentViewController:nil];
[self.connectVC.view removeFromSuperview];
[self.connectVC removeFromParentViewController];
[self awakeFromNib];
}

Xcode Error With More Than 5 UIImages [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
iPhone, “More than maximum 5 filtered album lists trying to register. This will fail.” Error
When I'm adding images to UIImageViews via Popover Controller or Modal View Controller, after the 4th image, when I go to add the 5th, Xcode's debugger outputs: "Error: More than maximum 5 filtered album lists trying to register. This will fail." It will still let me add in 5+ pictures, but only 4 of them save. I've done some research on here about this, and found this question:
iOS 5 GM: <Error>: More than maximum 5 filtered album lists trying to register. This will fail
The answer in here appears as though it is a bug with Apple, and that it should be ignored. Well, Apple is usually (somewhat) quick about fixing their Xcode bugs, and this has been around for a while, so I'm starting to wonder what the real cause is. I think this error is related to my app only saving up to 4 of the pictures.
Here is the code I'm working with:
- (IBAction)grabImage {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
_popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
[_popover presentPopoverFromRect:self.imageView.bounds inView:self.imageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else {
[self presentModalViewController:imgPicker animated:YES];
}
[self.imgPicker resignFirstResponder];
}
// Sets the image in the UIImageView
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
if (imageView.image == nil) {
imageView.image = img;
[self.array addObject:imageView];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView2.image == nil) {
imageView2.image = img;
NSLog(#"The image is a %#", imageView);
[self.array addObject:imageView2];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView3.image == nil) {
imageView3.image = img;
[self.array addObject:imageView3];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView4.image == nil) {
imageView4.image = img;
[self.array addObject:imageView4];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
if (imageView5.image == nil) {
imageView5.image = img;
[self.array addObject:imageView5];
[picker dismissModalViewControllerAnimated:YES];
[self.popover dismissPopoverAnimated:YES];
return;
}
}
UPDATE: Here is my current code:
- (IBAction)grabImage {
if (self.imgPicker == nil) {
self.imgPicker = [[UIImagePickerController alloc] init];
}
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
_popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
[_popover presentPopoverFromRect:self.imageView.bounds inView:self.imageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else {
[self presentModalViewController:imgPicker animated:YES];
}
[self.imgPicker resignFirstResponder];
}
From the other questions linked, it sounds like this is an Apple bug, but related to creating multiple UIImagePickerControllers. You're only presenting one image picker controller at a time, so maybe you should create one the first time you call your grabImage and then reuse it instead of creating a new one each time.

iOS: UIImagePickerController and ResignFirstResponder

I have an application that allows the user to select a photo from their camera roll, and display it in a UIImageView. But, after they tap on which image they would like to display, the camera roll's view does not disappear. So, I figured that I would need to simply call [sender resignFirstResponder];. But, this did not do the trick. I've been trying multiple things and doing searching around, but to no avail. I'm very new to Objective-C, so any help is much appreciated. Here is the code I'm working with:
(imgPicker is the UIImagePickerController.)
- (IBAction)grabImage(id)sender {
self.imgPicker = [[UIImagePickerController alloc] init];
self.imgPicker.delegate = self;
self.imgPicker.sourceType = UIImagePickerControllerSourceTypePhotoLibrary;
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
_popover = [[UIPopoverController alloc] initWithContentViewController:imgPicker];
[_popover presentPopoverFromRect:self.imageView.bounds inView:self.imageView permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
else {
[self presentModalViewController:imgPicker animated:YES];
}
[self.imgPicker resignFirstResponder];
}
And this may or may not be relevant to the issue:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)img editingInfo:(NSDictionary *)editInfo {
if (imageView.image == nil) {
imageView.image = img;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
return;
}
if (imageView2.image == nil) {
imageView2.image = img;
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
return;
}
}
You need just this line to dismiss modal picker in your delegate method:
[picker dismissModalViewControllerAnimated:YES];
resignFirstResponder in this case is useless
Try
[self dismissModalViewControllerAnimated:YES];
As you want to dismiss only picker view and not parent view of picker
you just have to use:
[picker dismissModalViewControllerAnimated:YES];
and you are done.