问题描述
我有一个应用程序,在xcode 4.5和ios 6.1滚动时工作得很好。
然而,在下载xcode 5和iOS 7之后,我的滚动视图不再有用了。???
I have an app which in xcode 4.5 and ios 6.1 worked perfectly fine when scrolling.However, after downloading xcode 5 and iOS 7 my scroll views does not work anymore.???
这是我的.h文件:
#import <UIKit/UIKit.h>
@interface GrillretterViewController : UIViewController
@property (strong, nonatomic) IBOutlet UIScrollView *grillretterScroller;
@property (assign) CGPoint rememberContentOffset;
@end
这是我的.m文件:
#import "GrillretterViewController.h"
@interface GrillretterViewController ()
@end
@implementation GrillretterViewController
@synthesize grillretterScroller, rememberContentOffset;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
[grillretterScroller setScrollEnabled:YES];
// Do any additional setup after loading the view.
}
- (void) viewDidAppear:(BOOL)animated {
[grillretterScroller setContentSize:CGSizeMake(300, 915)];
}
- (void)viewWillAppear:(BOOL)animated {
[super viewWillAppear:YES];
self.grillretterScroller.contentOffset = CGPointMake(0, 0);
}
- (void)viewWillDisappear:(BOOL)animated {
self.rememberContentOffset = self.grillretterScroller.contentOffset;
[super viewWillDisappear:animated];
}
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
self.grillretterScroller.contentOffset = CGPointMake(0, self.rememberContentOffset.y);
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
@end
请帮忙!我被困了!
祝你好运!
推荐答案
我解决了这可以通过在Scroll视图的主视图的File Inspector窗格中取消选择'Use Autolayout'来实现。
I solved this by deselecting 'Use Autolayout' in the File Inspector pane of main view within the Scroll View.
如果你想保持'Autolayout',请尝试'编辑 - >重新启动Autolayout问题 - >添加缺失约束'。关键约束似乎是底部空间:Superview,在我的情况下是-300,在视图的底部有300个滚动空间。
If you want to keep 'Autolayout' enabled, try 'Editor -> Reslove Autolayout Issues -> Add Missing Constraints'. The key constraint appears to be 'Bottom Space to: Superview and in my case was -300, giving 300 scroll space on the botton of the view.
这篇关于升级到iOS7 / xcode 5后,UIScrollView不会滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!