我在ipad的主视图中添加了4个子视图(UIScrollView,UITableView),每个视图都有自己的数据。
在Marco视图中,我尝试每隔3秒从服务器重新加载数据以刷新我的Marco视图
作为第一张照片。
当我在popoverView上删除一个时,我在ipad主视图上设置了3个Marco图标
popoverView上的图标确实删除了,但仍然在主视图上显示3个图标
作为第二和第三张照片...
必须从后台删除,然后打开应用程序才能正确查看..
作为第四张照片。
任何一个人都知道什么是问题。我尝试使用[marco_scrollview setNeedsDisplay]
但它没有用..
提前谢谢..
这是我获得Marcodata的代码:
- (void)getTheMacroURLData{
//[self.view setNeedsDisplay];
// [marco_scrollview setNeedsDisplay];
self.macroList = nil;
NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
EnvoTouchAppDelegate *appDelegate = (EnvoTouchAppDelegate *)[[UIApplication sharedApplication] delegate];
struct sockaddr_in Addr;
bzero(&Addr, sizeof(Addr));
Addr.sin_len = sizeof(Addr);
Addr.sin_family = AF_INET;
SCNetworkReachabilityRef target = SCNetworkReachabilityCreateWithAddress(NULL, (struct sockaddr *) &Addr);
SCNetworkReachabilityFlags flags;
SCNetworkReachabilityGetFlags(target, &flags);
if (flags & kSCNetworkReachabilityFlagsIsWWAN){
//Serial Number not save in the keychain now
NSString *theNewURLString = [NSString stringWithFormat:eGetAllMacrosSettingURL3G,[userDefaults objectForKey:@"ecsn"],appDelegate.udid];
NSURL *theNewURL = [NSURL URLWithString:theNewURLString];
self.macroList = [NSMutableArray arrayWithContentsOfURL:theNewURL];
}
if (flags & kSCNetworkFlagsReachable){
NSString *theNewURLString = [NSString stringWithFormat:eGetAllMacrosSettingURLWiFi,appDelegate.ipString,appDelegate.udid];
NSURL *theNewURL = [NSURL URLWithString:theNewURLString];
self.macroList = [NSMutableArray arrayWithContentsOfURL:theNewURL];
}
int k=0;
for (int i=0; i<[self.macroList count]; i++) {
int j=i%9;
if (j==0) {
k++;
}
UIButton *iconButton=[UIButton buttonWithType:UIButtonTypeCustom];
NSString *picString = [[self.macroList objectAtIndex:i] valueForKey: @"pid"];
UIImage *buttonImage = [UIImage imageNamed:picString];
[iconButton setImage:buttonImage forState:UIControlStateNormal];
[iconButton setTag:i];
[iconButton addTarget:self action:@selector(exeMacro:) forControlEvents:UIControlEventTouchUpInside];
[iconButton setFrame:CGRectMake(30+(i%9*80), 17+((k-1)*70), 48, 48)];
//[self.view addSubview:iconButton];
[marco_scrollview addSubview:iconButton];
if ([self.macroList count] > 18) {
[marco_scrollview setContentSize:CGSizeMake(320, 525 + (([self.macroList count]/4 - 4) * 70) )];
}
}
[marco_view addSubview:marco_scrollview];
}
我尝试每3秒重新加载一次数据。 我不知道为什么它不刷新Marco View ..
答案 0 :(得分:0)
显示使其看起来好像是在某个地方使用tableview。如果是这样,你是否在表视图上调用reloadData方法?