0
我使用以下代碼來滾動scrooll視圖圖像,滾動垂直
StoryViewScroller = [[[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 79.0f, 320.0f, 262)] autorelease];
StoryViewScroller.contentSize = CGSizeMake(NPAGES * 320.0f, StoryViewScroller.frame.size.height);
StoryViewScroller.pagingEnabled = YES;
StoryViewScroller.delegate = self;
StoryViewScroller.showsHorizontalScrollIndicator = NO;
StoryViewScroller.scrollsToTop = YES;
// Load in all the pages
for (i = 0; i < NPAGES; i++)
{
NSString *filename = [NSString stringWithFormat:@"%d.jpg", i+1];
UIImageView *iv = [[UIImageView alloc] initWithImage:[UIImage imageNamed:filename]];
iv.frame = CGRectMake(i * 320.0f, 0.0f, 320.0f, 262);
[StoryViewScroller addSubview:iv];
NSLog(@"I is :: %d" ,i);
[iv release];
}
[self.view addSubview:StoryViewScroller];
這使炒麪TOS滾動視圖從左到右和副versa.what我應該改變爲sroll視圖從上到下反之亦然。
sugggestions
問候
它的工作原理,但只得到1圖像.... – iscavengers 2010-09-17 09:08:59
肯定的 - 你需要正確的幀設爲您的圖像視圖 - 修改y座標原點,而不是×10 9循環。例如:iv.frame = CGRectMake(0.0f,i * 262.0f,320.0f,262); – Vladimir 2010-09-17 09:10:59
yea..how愚蠢的我m .....感謝弗拉基米爾。我可以一次顯示2張圖片嗎?就像它一次拍攝的1張照片一樣,如果想要在一個視圖上顯示2或3張圖像 – iscavengers 2010-09-17 09:17:03