English 中文(简体)
缩略语 观点和自治问题
原标题:UIScrollView and Autoration issues

我试图理解一个与“世界观”有关的问题。 我有一份UIScroll书,我想一页来讨论该装置的全部内容,并在轮值时加以调整。

在我的<座>viewDidLoad方法中,Im 测试:

NSArray *colors = [NSArray arrayWithObjects:[UIColor orangeColor], [UIColor cyanColor], [UIColor redColor], [UIColor greenColor], [UIColor blueColor], nil];

    for (int i = 0; i < colors.count; i++) {
        CGRect frame;
        frame.origin.x = _scrollView.bounds.size.width * i;
        frame.origin.y = 0;
        frame.size = _scrollView.bounds.size;

        UIView *subview = [[UIView alloc] initWithFrame:frame];
        subview.backgroundColor = [colors objectAtIndex:i];
        [_scrollView addSubview:subview];

    }

    _scrollView.contentSize = CGSizeMake(_scrollView.bounds.size.width * colors.count, _scrollView.bounds.size.height);

then I added in the didRotateFromInterfaceOrientation method:

_scrollView.contentSize = CGSizeMake(_scrollView.bounds.size.width * colors.count, _scrollView.bounds.size.height);

for (int i= 0; i< colors.count; i++)
{
    CGRect frame;
    frame.origin.x = _scrollView.bounds.size.width * i;
    frame.origin.y = 0;
    frame.size = _scrollView.bounds.size;


    UIView *subview= [[_scrollView subviews] objectAtIndex:i];

    subview.frame= frame;
}

这似乎在发挥作用,但我认为,在装置轮换期间,我似乎有点放慢。

Here s a screenshot of what happens when rotating: enter image description here

我认为,这种情况之所以发生,是因为我在轮换后改变了规模,但我试图在<>Restrong>willRotate ToInterfaceOrientation方法中处理这一变化,但结果是错误的。

  • 我处理这种错误吗?
  • What would be the correct approach?

TIA! S.

我处理这种错误吗?

最佳回答

您应当把改动<代码>中各项约束的代码改为,但放在一个动画片中(使用<代码>。 预测:0.4 估算:......]_使过渡顺利进行,而不是立即进行。

一项补充说明是,在“准备外向”中,家长的观点尚未改变,因此,你不能依赖其约束来计算意见的最后立场,而你必须人工这样做。

问题回答

暂无回答




相关问题
List Contents of Directory in a UITableView

I am trying to list the contents of Ringtones directory in a TableView, however, I am only getting the last file in the directory in ALL cells, instead of file per cell. This is my code: - (...

iPhone NSUserDefaults persistance difficulty

In my app i have a bunch of data i store in the NSUserdefaults. This information consists of an NSObject (Object1) with NSStrings and NSNumbers and also 2 instances of yet another object (Object2). ...

Writing a masked image to disk as a PNG file

Basically I m downloading images off of a webserver and then caching them to the disk, but before I do so I want to mask them. I m using the masking code everyone seems to point at which can be found ...

Resize UIImage with aspect ratio?

I m using this code to resize an image on the iPhone: CGRect screenRect = CGRectMake(0, 0, 320.0, 480.0); UIGraphicsBeginImageContext(screenRect.size); [value drawInRect:screenRect blendMode:...

Allowing interaction with a UIView under another UIView

Is there a simple way of allowing interaction with a button in a UIView that lies under another UIView - where there are no actual objects from the top UIView on top of the button? For instance, ...

热门标签