Sunday, February 12, 2012

About initWithFrame and buttonWithType

There's two way to init UIButton

1.init by buttonWithType
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = frame;

2.init by initWithFrame
UIButton *button = [[[UIButton alloc] initWithFrame:CGRectMake(0.0f,0.0f,100.0f,45.0f)] autorelease];


note1:

Some peopel suggest using +buttonWithType,

because that's the only way to specify the button type.

If you use +alloc and -initWithFrame: methods,

the buttonType is set to some standard value and you can't change the type afterwards

because the buttonType property is read only.


note2:

buttonWithType returns an autoreleased UIButton.

This way you don't have to worry about releasing it.

On the other hand, you don't own it, so you cannot release it when you want to.





4 comments:

  1. cara menggugurkan kandungan banyak sekali jenisnya dari non medis ( alami ) dan medis.
    Tapi cara apakah yang paling aman dan baik bagi wanita untuk minum obat aborsi

    ReplyDelete
  2. I visit everyday some sites and sites to read articles or reviews, but this weblog provides quality based articles.
    obat aborsi
    obat aborsi semarang
    obat aborsi bandung
    obat aborsi jogja

    ReplyDelete
  3. This is very educational content and written well for a change. It's nice to see that some people still understand how to write a quality post.!
    cara menggugurkan kandungan

    ReplyDelete
  4. It's actually a great and helpful piece of information. I am satisfied that you just shared this useful information for us.
    Thanks for sharing.
    obat aborsi

    ReplyDelete