On Jan 19, 2015, at 8:40 AM, Aaron Lewis <[email protected]> wrote:
> I'm trying to create a button programatically, something similar to this:
>
> UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
> [button setTitle:@"Click Me!" forState:UIControlStateNormal];
> button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0);
> [self.view addSubview: button];
>
> I had to set the frame otherwise it's invisible. And I'm using a fixed
> size here.
>
> Is that best practise to do it? I'm wondering if there's a "standard" size
1. The object has to have _some_ size and location. Presumably you know what
they should be. Suit yourself.
2. The frame is never really “fixed;” if you don't know what it should
eventually be, setting it by whim and doing the arithmetic later is the only
way. I use 0,0,100,100 for throwaway. Maybe my code would be cleaner if I
declared a global const/let CGRect with a name that flags my intent that it be
arbitrary.
3. Remember 44x44 points is the minimum usable size.
4. I am in the antisocial habit of answering off-topic questions. Help me
reform: Take the next one to cocoa-dev, which is about UIKit practice, and not
to a list restricted to Objective-C as a general-purpose programming language.
― F
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com
This email sent to [email protected]