Skip to content

Commit

Permalink
Fixes Boris-Em#248 issue that create touch event view on every changi…
Browse files Browse the repository at this point in the history
…ng orientation.
  • Loading branch information
canapio committed Jan 13, 2016
1 parent 30347ca commit 1ce4053
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 3 deletions.
32 changes: 29 additions & 3 deletions Classes/BEMSimpleLineGraphView.m
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,9 @@ @interface BEMSimpleLineGraphView () {

/// All of the X-Axis Labels
NSMutableArray *xAxisLabels;

/// Checking flag that createLayoutTouchReport method was called
BOOL isCreateLayoutTouchReport;
}

/// The vertical line which appears when the user drags across the graph
Expand Down Expand Up @@ -196,6 +199,7 @@ - (void)commonInit {
dataPoints = [NSMutableArray array];
xAxisLabels = [NSMutableArray array];
yAxisValues = [NSMutableArray array];
isCreateLayoutTouchReport = NO;

// Initialize BEM Objects
_averageLine = [[BEMAverageLine alloc] init];
Expand Down Expand Up @@ -226,8 +230,15 @@ - (void)drawGraph {
// Draw the graph
[self drawEntireGraph];

// Setup the touch report
[self layoutTouchReport];
if (!isCreateLayoutTouchReport) {
// Setup the touch report views only one time
[self createLayoutTouchReport];
isCreateLayoutTouchReport = YES;
} else {
// resize the touch report views
[self resizeLayoutTouchReport];
}


// Let the delegate know that the graph finished updates
if ([self.delegate respondsToSelector:@selector(lineGraphDidFinishLoading:)])
Expand Down Expand Up @@ -318,7 +329,7 @@ - (void)layoutNumberOfPoints {
}
}

- (void)layoutTouchReport {
- (void)createLayoutTouchReport {
// If the touch report is enabled, set it up
if (self.enableTouchReport == YES || self.enablePopUpReport == YES) {
// Initialize the vertical gray line that appears where the user touches the graph.
Expand Down Expand Up @@ -390,6 +401,21 @@ - (void)layoutTouchReport {
}
}

- (void) resizeLayoutTouchReport {
// If the touch report is enabled, resize views
if (self.enableTouchReport == YES || self.enablePopUpReport == YES) {
if (self.touchInputLine) {
self.touchInputLine.frame = CGRectMake(0, 0, self.widthTouchInputLine, self.frame.size.height);
}
if (self.panView) {
self.panView.frame = CGRectMake(10, 10, self.viewForBaselineLayout.frame.size.width, self.viewForBaselineLayout.frame.size.height);
}
if (self.popUpView) {
self.popUpView.frame = CGRectMake(0, 0, self.popUpLabel.frame.size.width + 10, self.popUpLabel.frame.size.height + 2);
}
}
}

#pragma mark - Drawing

- (void)didFinishDrawingIncludingYAxis:(BOOL)yAxisFinishedDrawing {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "1CA8AD815677B6FB0DD135F65EC4576AE68426CF",
"DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {

},
"DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
"1CA8AD815677B6FB0DD135F65EC4576AE68426CF" : 0,
"3A216D26EB93D9EB79DE1E013DBEF75CF4509620" : 0
},
"DVTSourceControlWorkspaceBlueprintIdentifierKey" : "F1F15B84-6620-4046-8D91-529CC20CD7C2",
"DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
"1CA8AD815677B6FB0DD135F65EC4576AE68426CF" : "BEMSimpleLineGraph",
"3A216D26EB93D9EB79DE1E013DBEF75CF4509620" : ""
},
"DVTSourceControlWorkspaceBlueprintNameKey" : "SimpleLineChart",
"DVTSourceControlWorkspaceBlueprintVersion" : 204,
"DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "Sample Project\/SimpleLineChart.xcodeproj",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/Boris-Em\/BEMSimpleLineGraph.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "1CA8AD815677B6FB0DD135F65EC4576AE68426CF"
},
{
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.dowjones.net\/DJMobile\/ios-thesituation.git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
"DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "3A216D26EB93D9EB79DE1E013DBEF75CF4509620"
}
]
}

0 comments on commit 1ce4053

Please sign in to comment.