我有一个从Web服务器拉出的随机调查表。我需要有一个按钮执行(setNeedsDisplay)刷新......当我与错误点击了按钮的应用程序崩溃的页面:刷新视图controller.m
*终止应用程序由于未捕获的异常“NSInvalidArgumentException”,原因是:“ - [ExercisesViewController setNeedsDisplay ]:无法识别的选择发送到实例0x6a1e840' ***第一掷调用堆栈: (0x13f3022 0x1584cd6 0x13f4cbd 0x1359ed0 0x1359cb2 0x963054 0x974fc6 0x57c0 0x13f4e99 0x4014e 0x400e6 0xe6ade 0xe6fa7 0xe6266 0x301a1a 0x13c799e 0x135e640 0x132a4c6 0x1329d84 0x1329c9b 0x12dc7d8 0x12dc88a 0x3d626 0x1f96 0x1f05) 终止叫做抛出例外*
//Add refreshing agenda
scrollViewFrame = CGRectMake(0, 200, 80, 40);
mark = [UIButton buttonWithType:UIButtonTypeRoundedRect];
mark.frame = scrollViewFrame;
[mark setTitle:@"Get Score" forState:UIControlStateNormal];
[mark setBackgroundColor:[UIColor clearColor]];
[mark addTarget:self
action:@selector(markButtonSelected:) forControlEvents:UIControlEventTouchUpInside];
[scrollView addSubview:mark];
...
- (IBAction)markButtonSelected:(id)sender{
[self performSelectorInBackground:@selector(setNeedsDisplay) withObject:nil];
}
这是一个语法问题?我读here,这是与线程有关。有人可以解释关于线程还是有更直接的方法? Thanx提前...
你不应该做与UIViews东西在后台线程 – 2012-04-26 13:12:50
如此。好点子。我专注于在视图与控制器上调用setNeedsDisplay。 – mprivat 2012-04-26 13:17:22