Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4001512
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T07:54:51+00:00 2026-05-20T07:54:51+00:00

I am trying to create a new button of a specific size in a

  • 0

I am trying to create a new button of a specific size in a UIView. As it happens, this view will be used in a tableViewCell, like this.

UIImageCtrlBtnView *newView = [self initImageCtrlBtnsInViewWithHeight: 50 withWidth : 280];
[cell.contentView addSubview:newView];

I create a new view and a bunch of buttons in the method initImageCtrlBtnsInViewWithHeight.

-(UIView*) initImageCtrlBtnsInViewWithHeight: (CGFloat) rowHeight withWidth: (CGFloat) rowWidth {

UIView *newView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, rowWidth, rowHeight)];
newView.tag = kImageCtrlBtnViewTag;
newView.clipsToBounds = YES;

    // finding the right size of the button by setting the button size to some fraction
    // of the view size.
CGRect largeButtonFrame = CGRectMake(rowWidth*0.1+newView.frame.origin.x, rowHeight*0.2+newView.frame.origin.y, rowWidth*0.8, rowHeight*0.6);
UIButton *largeMoreButton = [UIButton buttonWithType:UIButtonTypeCustom];
largeMoreButton.tag = kLargeMoreBtnTag;
[largeMoreButton setTitle:@"Add Photo" forState:UIControlStateNormal ];         
[largeMoreButton setFrame: largeButtonFrame];

    // I check the size of the button frame.
   DLog(@"large more btn frame: %d, %d, %d, %d", largeMoreButton.frame.origin.x, largeMoreButton.frame.origin.y, largeMoreButton.frame.size.width, largeMoreButton.frame.size.height);    
etc.

The problem is that when I get the button back after the setFrame, it is huge. Here is the output from the log. The button thinks it is 1076101120 high!

large more btn frame: 0, 1077706752, 0, 1076101120

I checked the value of the largeButtonFrame rectangle in the debug log, and it is as I would expect.

(gdb) print largeButtonFrame
$1 = {
origin = {
   x = 28.5, 
   y = 10
}, 
size = {
  width = 228, 
  height = 30
}
}

In the end, when the view is shown in the tableView, I get this error message, and a bunch of CGContext errrors.

-[<CALayer: 0xff7b550> display]: Ignoring bogus layer size (320.000000, 1120403456.000000)
-[<CALayer: 0xff778a0> display]: Ignoring bogus layer size (300.000000, 1120403456.000000)

When my table is shown, the buttons look like the right size, but this cell basically extends forever in the table view, and I can’t scroll to any of the other cells behind it.

I’ve also tried to set the button size different ways (e.g. set the button bounds, and then center it to the view. Or use the UIButton buttonWithType creator, then setting the frame), but none of these seem to make a difference.

Googling the error message, this error message only seems to happen when folks are trying to do animation. But I am not trying to do any animation here, just setting some buttons.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-20T07:54:51+00:00Added an answer on May 20, 2026 at 7:54 am

    Uh yea… it’s a float.

    DLog(@"large more btn frame: %f, %f, %f, %f", largeMoreButton.frame.origin.x, largeMoreButton.frame.origin.y, largeMoreButton.frame.size.width, largeMoreButton.frame.size.height);    
    

    With the warnings you are getting when you’re running the app, I’m not entirely sure what those are, but I’d be willing to bet you aren’t using a float value for the size, that’s just based on the numbers it’s giving you, so I’m not 100% sure.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Trying to get custom Done button in Utility Application Create new project in Xcode
I'm trying to create a new Excel file using jxl, but am having a
I am trying to create a new contact using Dynamic Entity. The sample i
I am trying to create a new website on a remote server via msbuild
I'm trying to create a new module for Sitefinity. I'm basing my module off
Using Prototype 1.6's new Element(...) I am trying to create a <table> element with
I'm new to postgreSQL and I have a simple question: I'm trying to create
I am trying create a WCF service that leverages the WPF MediaPlayer on the
Trying to create a QtRuby application, I get the following error: /usr/lib64/ruby/site_ruby/1.8/Qt/qtruby4.rb:2144: [BUG] Segmentation
Trying to create a user account in a test. But getting a Object reference

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.