我有一个简单的例子,我有一个实用程序应用程序项目,其上有一个UIScrollView
。当我单击信息按钮翻转屏幕并返回时UIScrollView
现在没有响应。不仅如此,我故意将滚动条放在左上角的Interface Builder中,然后以编程方式将其设置在中心。当我从翻转侧回来时,它向上移动到左上角并且没有反应。为什么呢?
这是我的.h
文件:
#import "POCFlipsideViewController.h"
@interface POCMainViewController : UIViewController <POCFlipsideViewControllerDelegate, UIScrollViewDelegate>
@property (nonatomic,retain) IBOutlet UIScrollView *scroller;
@end
这是我的.m文件
#import "POCMainViewController.h"
@interface POCMainViewController ()
@end
@implementation POCMainViewController
@synthesize scroller =_scroller;
- (void)viewDidAppear:(BOOL)animated
{
[_scroller setContentSize:CGSizeMake(80.0f, 320.0f)];
[_scroller setFrame:CGRectMake(120, 131, 80, 214)];
[super viewDidAppear:animated];
}
- (void)viewDidLoad
{
_scroller.delegate = self;
_scroller.showsVerticalScrollIndicator = NO;
_scroller.decelerationRate = UIScrollViewDecelerationRateFast;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
#pragma mark - Flipside View
- (void)flipsideViewControllerDidFinish:(POCFlipsideViewController *)controller
{
[self dismissViewControllerAnimated:YES completion:nil];
}
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"showAlternate"]) {
[[segue destinationViewController] setDelegate:self];
}
}
@end
其余的是直接来自Xcode的锅炉板。
答案 0 :(得分:0)
我发现UIScrollView的罪魁祸首通常是自动布局。在Storyboard中,突出显示主视图控制器下的视图元素,然后打开右侧列中的“显示文件检查器”窗口。在“Interface Builder Document”下,取消选择“Use Auto Layout”,看看是否能解决您的问题。