質問

Is here any way to set UIScrollview orientation by coding? Actually I am creating scrollview programmatically and want to set its orientation landscape. I can't find any way on google and apple's docs.

役に立ちましたか?

解決

With scrollviews, you don't give them an orientation exactly. You set their frame and their content size. So if you set the frame to 1024 x 768 and the content size is 3000 x 768, the scrollview will automatically allow scrolling horizontally. And because you set the frame to a landscape ratio/size, the scrollview will be in a landscape "orientation." Pseudo code below to help.

UIScrollView *scrollView = [[UIScrollView alloc] initWithFrame:CGRectMake(0,0,1024,768)];
[scrollView setContentSize:CGSizeMake(3000, 768)];

Let me know if this doesn't help and I can elaborate or help further.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top