我创建视图并释放所有对象。我使用了NSTimer和
//at viewdidload
NSTimer *timer = [NSTimer scheduledTimerWithTimeInterval: 15.0
target: self
selector:@selector(selectorSwitcher:)
userInfo: nil repeats:YES];
NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer:timer forMode: NSDefaultRunLoopMode];
-(void)selectorSwitcher:(NSTimer *)timer {
[self viewDidLoad];
}
但myviews无法从scrollview中删除。创建更多其他人的观看次数。我该如何解决这个问题? 感谢
if (tempView.frame.origin.x > createview.frame.size.width) {
tempLabel = [[UILabel alloc] initWithFrame:CGRectMake((lblname_marginleft + (i * widthOfView))-((i/sutun)*mview_width), lblname_margintop + ((i/sutun) * heightOfView), labelwidth, labelheight)];
tempNumber = [[UILabel alloc] initWithFrame:CGRectMake((lblnumber_marginleft + (i* widthOfView))-((i/sutun)*mview_width), lblnumber_margintop + ((i/sutun) * heightOfView), labelwidth, labelheight)];
tempyuzde= [[UILabel alloc] initWithFrame:CGRectMake((15 + (i*widthOfView))-((i/sutun)*mview_width), 10 + ((i/sutun) * heightOfView), labelwidth, labelheight)];
tempView = [[UIView alloc] initWithFrame:CGRectMake((10 + (i* widthOfView)) - ((i/sutun)*mview_width), ((i/sutun) * heightOfView), widthOfView, heightOfView)];
答案 0 :(得分:2)
您不应该调用viewDidLoad
- 系统会在视图加载后调用它。要加载视图,只需执行以下操作:
UIView *view = self.view;
调用self.view
隐式加载XIB文件。但是,系统还会在需要时自动加载视图 - 您要实现哪些功能?
此外,你不应该打电话
NSRunLoop *runner = [NSRunLoop currentRunLoop];
[runner addTimer:timer forMode: NSDefaultRunLoopMode];
由于通过调用scheduledTimerWithTimeInterval...
您已经安排了计时器 - 您无需再次安排计时器。