0
내 스크롤보기가 튀어 나오지만 스크롤하지 않습니다.ScrollView가 제대로 스크롤되지 않습니다.
- (void)populateStampList {
// create a mutable array to populate
imageNames = [[NSArray alloc] init];
NSMutableArray *mImageNames = [[NSMutableArray alloc] init];
// List of images
NSString *img1 = @"moustache";
NSString *img2 = @"whitem";
NSString *img3 = @"blackm";
NSString *img4 = @"monacle";
NSString *img5 = @"tophat";
// add images to mutable array
[mImageNames addObject:img1];
[mImageNames addObject:img2];
[mImageNames addObject:img3];
[mImageNames addObject:img4];
[mImageNames addObject:img5];
// set mutable array to array;
imageNames = mImageNames;
CGFloat contentSizeWidth = 0.0;
CGSize newSize = _scrollViewOutlet.frame.size;
for(int i = 0; i < [imageNames count]; i++){
NSData *archivedData = [NSKeyedArchiver archivedDataWithRootObject:_firstImage];
UIButton *button = [NSKeyedUnarchiver unarchiveObjectWithData: archivedData];
[button addTarget:self action:@selector(badgePressed:) forControlEvents:UIControlEventTouchUpInside];
button.tag = i+1;
CGRect newFrame = CGRectMake(_firstImage.frame.origin.x, _firstImage.frame.origin.y, _firstImage.frame.size.width, _firstImage.frame.size.height);
newFrame.size.width = _firstImage.frame.size.width;
newFrame.size.height = _firstImage.frame.size.height;
newFrame.origin.x += (20+_firstImage.frame.size.width) * i;
newFrame.origin.y = _firstImage.frame.origin.y ;
[button setFrame:newFrame];
contentSizeWidth = (20+button.frame.size.width) * i;
NSLog(@"button frame size: %f", _firstImage.frame.size.width);
NSString *imageName = [[imageNames objectAtIndex:i] stringByAppendingString:@".png"];;
NSString *documentsDirectory = [utils getDocumentsDirectoryPath];
//UIImage *image = [utils loadImage:imageName ofType:@"png" inDirectory:documentsDirectory];
UIImage *image = [UIImage imageNamed:imageName
]; [button setImage:image forState:UIControlStateNormal];
[button setImage:image forState:UIControlStateSelected];
[[button imageView] setContentMode: UIViewContentModeScaleAspectFit];
[button setAlpha:1.0f];
[[button imageView] setImage:image];
[_scrollViewOutlet addSubview:button];
NSLog(@"scrollViewFrame size: %f", _scrollViewOutlet.frame.size.width);
NSLog(@"scrollViewFrame size: %f", _scrollViewOutlet.frame.size.height);
newSize.width = contentSizeWidth+400;
[_scrollViewOutlet setScrollEnabled:YES];
[_scrollViewOutlet setContentSize:newSize];
NSLog(@"scrollviewOutlet Content Width: %f", _scrollViewOutlet.contentSize.width);
NSLog(@"scrollviewOutlet Content Height: %f", _scrollViewOutlet.contentSize.height);
}
}
여기
내 NSLogs :
2013-08-08 18:28:39.856 xxxx[4647:907] scrollViewFrame size: 320.000000
2013-08-08 18:28:39.857 xxxx[4647:907] scrollViewFrame size: 86.000000
2013-08-08 18:28:39.858 xxxx[4647:907] scrollviewOutlet Content Width: 768.000000
2013-08-08 18:28:39.859 xxxx[4647:907] scrollviewOutlet Content Height: 86.000000
바운스되지만 스크롤 할 수 없다는 것은 무엇을 의미합니까? – runmad
그래서 ... 내 손가락을 아래로 잡고 드래그 할 수 있지만 scrollview 프레임의 가장자리에서 튀어 나오지만 scrollview 콘텐츠 크기의 끝까지 끌 수는 없습니다. 말이 돼? – jimbob
실제로 개체를 추가 할 수 있도록 변경할 수없는 배열에 배열을 할당합니다. 그것에 대해 혼란스러운 것은 무엇입니까? 왜 단순한 코드가 혼란 스럽다는 이야기를하는 경우에도 귀찮게했습니다. – jimbob