關於該應用程序:自定義openGL地圖,由具有在基本地圖上繪製疊加層功能的圖塊構建。該應用程序對於iPad和iPhone都是通用的。一些覆蓋圖是基於圖塊的,它們工作得很好。有些是由地圖上的特定座標繪製的圓圈構成的。點擊圓圈打開彈出視圖,並在地圖上顯示關於此特定點的信息。在iPhone庫WEPopover用於實現類似於UIPopoverViewController的功能。EXC_BAD_ACCESS在打開WEPopover時崩潰glDrawArrays
這個問題只發生在iPhone上,只在設備上出現。當覆蓋圖由大量圓圈組成時,使用info打開彈出視圖有時會導致覆蓋層閃爍,並最終導致EXC_BAD_ACCESS在行上崩潰:glDrawArrays(GL_LINE_LOOP,0,360); 這隻發生在iPhone上,永遠不會在iPad或模擬器上。
代碼點點:
繪製黑色圓圈與白色的輪廓:在iPhone
for (int i = [pointsArray count]-1; i >= 0; i--) {
int pinColor = 0xffff0000;
static GLfloat vertices[720];
for (int i = 0; i < 720; i += 2) {
vertices[i] = (cos(DEGREES_TO_RADIANS(i)) * scale * 1.5);
vertices[i+1] = (sin(DEGREES_TO_RADIANS(i)) * scale * 1.5);
}
glVertexPointer(2, GL_FLOAT, 0, vertices);
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glEnable(GL_BLEND);
glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
for (int dx = x0; dx <= x1; dx++)
{
glPushMatrix();
GLubyte a = (pinColor >> 24) & 0xff;
a = MIN((GLubyte) (opacity * 255), a);
glColor4ub(0, 0, 0, a);
GLfloat xx = point.x - centerX + dx * mapWidth;
xx *= zoom;
glTranslatef(xx, yy, 0);
glDrawArrays(GL_TRIANGLE_FAN, 0, 360); <-----sometimes crash here
int color = 0xffffffff;
GLubyte n = (color >> 24) & 0xff;
GLubyte r = (color >> 16) & 0xff;
GLubyte g = (color >> 8) & 0xff;
GLubyte b = (color >> 0) & 0xff;
n = MIN((GLubyte) (opacity * 255), n);
glColor4ub(r,g,b,n);
glLineWidth(1);
glDrawArrays(GL_LINE_LOOP, 0, 360); <------crash here
glLineWidth(1);
glPopMatrix();
}
glDisable(GL_BLEND);
glDisableClientState(GL_VERTEX_ARRAY);
glDisableClientState(GL_TEXTURE_COORD_ARRAY);
glVertexPointer(2, GL_FLOAT, 0, 0);
}
開幕酥料餅:
WEPopoverController *_popover = [[WEPopoverController alloc] initWithContentViewController:pointDetails];
_popover.popoverContentSize = pointDetails.view.frame.size;
if ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft || [[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)
{
CGRect myrect2 = CGRectMake(xx,yy, 1, 1);
[_popover presentPopoverFromRect:myrect2 inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
} else {
CGRect myrect2 = CGRectMake(xx, yy, 1, 1);
[_popover presentPopoverFromRect:myrect2 inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
}
self.detailsPopIphone = _popover;
[_popover release];
每次觸摸屏幕時
(移動規模的地圖,open popover)重新渲染openGL地圖。
我很樂意提供任何附加信息或代碼。