Skip to content
This repository has been archived by the owner on May 28, 2024. It is now read-only.

show in center of parent view #12

Open
uranpro opened this issue Aug 4, 2011 · 10 comments
Open

show in center of parent view #12

uranpro opened this issue Aug 4, 2011 · 10 comments

Comments

@uranpro
Copy link

uranpro commented Aug 4, 2011

  • (void)show {
    UIView *sv = [self.view superview];
    self.view.center = CGPointMake(self.view.center.x, sv.bounds.origin.y + sv.bounds.size.height / 2);

    [__view show];
    }

@dhoerl
Copy link

dhoerl commented Aug 15, 2011

You can do this yourself - if you look there is a "center" property that you can set before you "show".

@uranpro
Copy link
Author

uranpro commented Aug 16, 2011

yes, but this property not used.

@dhoerl
Copy link

dhoerl commented Aug 16, 2011

Ah, now I get it. Its used once at initialization time, but if the
superview changes size then it's never updated or changed. If the
setCenter: method were to change the center point, that would probably
suffice to meet your needs.

@dhoerl
Copy link

dhoerl commented Aug 17, 2011

I just added this to my fork and tested it.

  • (void)setCenter:(CGPoint)pt
    {
    center = pt;

    if(__view) __view.center = center;
    }

@uranpro
Copy link
Author

uranpro commented Aug 19, 2011

See my pull request

@cwagdev
Copy link

cwagdev commented Aug 23, 2011

I was having issues with my HUD not appearing in the center on the iPad...

I took uranpro's lead and revised my show method with the following which fixed my issue...

- (void)show {
    UIView *sv = [self.view superview];
    self.view.center = CGPointMake(sv.bounds.origin.x + sv.bounds.size.width/2, sv.bounds.origin.y + sv.bounds.size.height/2);
    [__view show];
}

@uranpro
Copy link
Author

uranpro commented Aug 24, 2011

I added "autocenter" property in my fork =)

@dhoerl
Copy link

dhoerl commented Aug 24, 2011

On 8/24/11 3:06 AM, uranpro wrote:

I will add "autocenter" property is my fork=)

Good idea!

David

@dhoerl
Copy link

dhoerl commented Sep 1, 2011

On 8/23/11 6:25 PM, cwagner wrote:

I was having issues with my HUD not appearing in the center on the iPad...

I took uranpro's lead and revised my show method with the following which fixed my issue...

- (void)show {
     UIView *sv = [self.view superview];
     self.view.center = CGPointMake(sv.bounds.origin.x + sv.bounds.size.width/2, sv.bounds.origin.y + sv.bounds.size.height/2);
  [__view show];
}

Understood, but making the center property settable means that you can
set it elsewhere. The way you have this now, if you ever want it
somewhere besides the center, there is no way to set it. It always has
to be in the center.

@cwagdev
Copy link

cwagdev commented Sep 1, 2011

Understood, but making the center property settable means that you can
set it elsewhere. The way you have this now, if you ever want it
somewhere besides the center, there is no way to set it. It always has
to be in the center.

You are correct, but for this app that is how we always want it to appear.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants