我有一个带有两个选项卡的选项卡式应用程序。刷新ios中的选项卡式应用程序中的UIview
在第二个选项卡上,我绘制了一个图。
但每次按下此选项卡时,UIview都不会刷新。
我试过,
[self.view setNeedsDisplay]
inside
- (void)viewDidLoad
但仍然没有刷新。
我试图从- (void)viewDidLoad
代码粘贴到-(void)viewDidAppear
但是什么都没有发生。
等待一个答案。
编辑:整个源代码
- (void)viewDidLoad
{
//[self.view setNeedsDisplay];
Sensor_VisualizationAppDelegate *delegate = (Sensor_VisualizationAppDelegate *)[[UIApplication sharedApplication] delegate];
valuePass = delegate.valuepass;
timePass = delegate.timepass;
NSNumber *value1 = [valuePass objectAtIndex:0];
NSNumber *value2 = [valuePass objectAtIndex:1];
NSNumber *value3 = [valuePass objectAtIndex:2];
NSNumber *value4 = [valuePass objectAtIndex:3];
NSNumber *value5 = [valuePass objectAtIndex:4];
NSNumber *value6 = [valuePass objectAtIndex:5];
NSNumber *value7 = [valuePass objectAtIndex:6];
NSString *time1 = [timePass objectAtIndex:0];
NSString *time2 = [timePass objectAtIndex:1];
NSString *time3 = [timePass objectAtIndex:2];
NSString *time4 = [timePass objectAtIndex:3];
NSString *time5 = [timePass objectAtIndex:4];
NSString *time6 = [timePass objectAtIndex:5];
NSString *time7 = [timePass objectAtIndex:6];
OVGraphView *graphview=[[OVGraphView alloc]initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.height, 300) ContentSize:CGSizeMake(960, 300)];
graphview.reverse=YES;
graphview.graphcolor=[UIColor colorWithRed:0.31 green:0.73 blue:0.78 alpha:1.0];
[self.view addSubview:graphview];
[graphview setPoints:@[ [[OVGraphViewPoint alloc]initWithXLabel:time1 YValue:value1],
[[OVGraphViewPoint alloc]initWithXLabel:time2 YValue:value2],
[[OVGraphViewPoint alloc]initWithXLabel:time3 YValue:value3],
[[OVGraphViewPoint alloc]initWithXLabel:time4 YValue:value4],
[[OVGraphViewPoint alloc]initWithXLabel:time5 YValue:value5],
[[OVGraphViewPoint alloc]initWithXLabel:time6 YValue:value6],
[[OVGraphViewPoint alloc]initWithXLabel:time7 YValue:value7]
]];
[super viewDidLoad];
}
你是如何绘制图形的?只要切换到该选项卡,viewWillAppear/viewDidAppear就会被调用。 viewDidLoad只会在第一次加载视图时调用。 –
@JamesP我正在使用名为[OVGraphView](https://github.com/owenv/OVGraphView)的框架来绘制它,Lemme发布了整个代码。但是,我应该如何将viewDIdload链接到我的UIview,因为当我试图将代码复制粘贴到ViewDidLoad时,什么都没有发生。 – spaniard89
我对此并不熟悉,但如果您在graphView上调用setNeedsDisplay,而不是self.view,会怎么样。 (这应该在viewWillAppear里面)。 –