我在 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..