KVO 值变化刷新界面 //注册调用 [testPerson addObserver:self forKeyPath:@"height" options:NSKeyValueObservingOptionNew context:nil]; //回调函数 - (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context { if ([keyPath isEqualToString:@"height"]) { NSLog(@"Height is changed! new=%@", [change valueForKey:NSKeyValueChangeNewKey]); } else { [super observeValueForKeyPath:keyPath ofObject:object change:change context:context]; } } UIScrollView - (void) setup{ //scrollview self.scrollView.delegate = self; int imagecount = 4; self.scrollView.contentSize = CGSizeMake(imagecount * PKScreenW, 0); self.scrollView.bounces = NO; //回弹 self.scrollView.showsHorizontalScrollIndicator = NO; //分页 self.scrollView.pagingEnabled = YES; //添加图片 到 scrollView int imageW = PKScreenW; for (int i = 0; i < imagecount; i++) { NSString *imagename = @"Starting_Image";//[NSString stringWithFormat:@"%d", i + 1]; UIImageView *image = [[UIImageView alloc] initWithImage:[UIImage imageNamed:imagename]]; image.userInteractionEnabled = YES; image.size = CGSizeMake(PKScreenW, PKScreenH-PKNavigationH); PKLog(@"%f,%f",self.size.width,self.size.height); image.x = i * imageW; image.y……
阅读全文