سؤال

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