Question

There are few questions regarding this topic in stackoverflow. But none of the solutions are working for me.

I have a requirement to show pop up when user clicks on the row of a table view. Again this pop-up should contain a tableView. Since Apple recommandation is not use tableView inside a alertView,So, I need to use normal UIView with lesser size.

UIView is drawn using storyboard.

Programmatically I am trying following code to reduce the size.

- (void)viewDidLoad
{
    [super viewDidLoad];

    CGRect newFrame = self.view.frame;

    newFrame.size.width = 200;

    newFrame.size.height = 200;

    [self.view setFrame:newFrame];
}

But it is not working.

Was it helpful?

Solution

CGRect is not only width and height, its also x and y. So do this:

CGRect newFrame = CGRectMake( self.view.frame.origin.x, self.view.frame.origin.y, 200, 200);

self.view.frame = newFrame;

This does only effect the width and height.

OTHER TIPS

Probably the View that you are trying to modify is the one attached to the UIViewController via Storyboard, you will not be able to modify that one, try creating another one either with Storyboards or programmatically.

Since you are requirement is to display a popup , I would suggest you if its iPAD then go ahead with UIPopoverController and if its iPhone then just create a new full screen UIView with the transparent background (clear background) and then create one more UIView with new frames and make sure the frame size is in middle and attach it(Add subview) .

Also the procedure what you is doing won't work.Create a new UIView and change the frame and then attach or add subView to your main View

This will solve your issue.

I think you are looking for UIPopOverController with tableView..

Refer this tutorial

http://www.raywenderlich.com/29472/ipad-for-iphone-developers-101-in-ios-6-uipopovercontroller-tutorial

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top