Adel
Adel

Reputation: 411

How to present resized UIViewController in UITableViewController - iPhone

I have a UITableViewController with multiple rows, when a row is pressed, I would like to present a ViewController, which has small view with Facebook and twitter buttons, on top of the table view ( the tableview still can be seen).

Although, I have resized the view of the ViewController in storyboard and have unchecked "resize view from nip" but when the ViewController is presented, its view appears as full screen.

I tried to add it as subview but then it is just added to the first row of the tableView.

can you please tell me what I'm doing wrong?

Thank you.

Upvotes: 0

Views: 235

Answers (2)

Toseef Khilji
Toseef Khilji

Reputation: 17409

If you only want to share info you can use UIActivityViewController,

  //Include an array of things being attached to the ActivityViewController
  //The Array cannot be nil, you must provide something. Either an image or text or both

  NSArray *activityItems = @[@"Hello Share",[UIImage imageNamed:@"someImage"]];
  UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
  activityViewController.excludedActivityTypes = @[UIActivityTypePostToWeibo, UIActivityTypeAssignToContact ];    // means this item you dont want to show while sharing 
  [self presentViewController:activityViewController animated:YES completion:NULL];

Upvotes: 1

Simon
Simon

Reputation: 1394

You mighty try something like the following:

1) Initialise your facebook view controller

2) Add your facebook view controller as a child view controller:

[self addChildViewController:self.facebookController];

3) Set the required frame:

[self.facebookController.view setFrame:CGRectMake(x, y, w, h)];

4) Add the facebook controllers view as necessary

[self.requiredView addSubview:self.facebookController.view];

I haven't tried this so I don't know if it works, especially since I haven't done anything with Storyboards yet. It's still worth a try.

Upvotes: 1

Related Questions