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 7947277
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T01:23:10+00:00 2026-06-04T01:23:10+00:00

I have app to create a graph i have created a view based app

  • 0

I have app to create a graph i have created a view based app and then add the code for creating graph in it but it does not disply the graph. If use same code to create a separate UIView then it works other wise not

   #import <UIKit/UIKit.h>
  #import "ECGraph.h"
  #import "ECGraphItem.h"
 @class GraphsViewController;
 @interface Display : UIView {

NSArray *percentages;

int myY;
ECGraph *graph;
ECGraphItem *item1;
ECGraphItem *item2;


   }
  @property(nonatomic,retain)NSArray*percentages;

 -(void) setPercentageArray:(NSArray*) array;

 @end


 #import "Display.h"
 #import "ECGraph.h"
 @implementation Display
 @synthesize percentages;

- (id)initWithFrame:(CGRect)frame {

self = [super initWithFrame:frame];
if (self) {
    // Initialization code.
}
return self;
}


- (void)drawRect:(CGRect)rect {


CGContextRef _context = UIGraphicsGetCurrentContext();



graph = [[ECGraph alloc] initWithFrame:CGRectMake(500,-320,320, 200) withContext:_context isPortrait:NO];


item1 = [[ECGraphItem alloc] init];

item2 = [[ECGraphItem alloc] init];
/*
ECGraphItem *item1 = [[ECGraphItem alloc] init];

ECGraphItem *item2 = [[ECGraphItem alloc] init];*/

item1.isPercentage = YES;



item1.yValue=myY;




item1.width = 35;
item1.name = @"item1";

item2.isPercentage = YES;
item2.yValue =17;

item2.width = 35; 
item2.name = @"item2";



[graph setXaxisTitle:@"name"];
[graph setYaxisTitle:@"Percentage"];
[graph setGraphicTitle:@"Histogram"];
[graph setDelegate:self];
[graph setBackgroundColor:[UIColor colorWithRed:220/255.0 green:220/255.0 blue:220/255.0 alpha:1]];



NSArray *items = [[NSArray alloc] initWithObjects:item1,item2,nil];


[graph drawHistogramWithItems:items lineWidth:2 color:[UIColor blackColor]];




}

I am adding this view in GraphsViewController but its not showing anything

// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

 - (void)viewDidLoad {
[super viewDidLoad];

[self createGraph];



percentages = [NSArray arrayWithObjects:@"80",@"17", nil];

display = [[Display alloc] init];

[self.view addSubview:display];

[display setPercentageArray:percentages];

}
  • 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-06-04T01:23:12+00:00Added an answer on June 4, 2026 at 1:23 am

    You should do the drawing in a separate UIView object and add it as a subview to your view controller’s view. That’s the way it is supposed to work.

    The UIView class uses an on-demand drawing model for presenting
    content.

    Source: View Programming Guide for iOS

    as opposed to

    The UIViewController class provides the fundamental view-management
    model for all iOS apps. … A view controller manages a set of views
    that make up a portion of your app’s user interface.

    Source: UIViewController Class Reference

    Edit:

    // ...
    display = [[Display alloc] init];
    CGRect dFrame = CGRectMake(50, 50, 320, 200); // change these to whatever values you need
    [display setFrame:dFrame];
    [self.view addSubview:display];
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an app that does an iteration to create points on a graph
Actually, in my app, I have created a graph using achartEngine . In these
I have create web app in MVS 3 but failed to display alert message
I have an app where I create many uiviews and add them to the
I have to create app that provides online radio streaming (icecast), preferably .ogg format.
I have an app that allows you to create Home shortcuts to a specific
I have recently changed my web app to create a database connection per command
I have to create an app in which I must set a date and
I have an iPhone app and would like to create iPad version of it.
I have a flex app which allows user to create some content. this content

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.