Skip to content
This repository has been archived by the owner on Dec 2, 2020. It is now read-only.

Fixes issue that create touch event view on every changing orientation. #249

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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"
}
]
}