嘿伙计们,我有一个嵌入视图的UI Scrollview。然而;即使我在IB Keypath中设置了contentSize,它仍然不会滚动?
有什么建议吗?
@interface DigitalVC ()
{
NSArray *switchArrayOut;
NSArray *switchArrayIn;
AppDelegate *appDelegate;
UIColor *custom1;
UIColor *custom2;
UIColor *custom3;
UIColor *custom4;
}
@property (weak,nonatomic) NCBoardManager *manager;
@property (weak,nonatomic) IBOutlet UIButton *resetCounter;
@property (weak,nonatomic) IBOutlet UISwitch *liveSwitch;
@property (weak,nonatomic) IBOutlet UILabel *outputLabel;
@property (weak,nonatomic) IBOutlet UILabel *inputLabel;
@property (weak,nonatomic) IBOutlet UILabel *counterLabel;
@property (weak,nonatomic) IBOutlet UISwitch *outputSwitch0;
@property (weak,nonatomic) IBOutlet UISwitch *outputSwitch1;
@property (weak,nonatomic) IBOutlet UISwitch *outputSwitch2;
@property (weak,nonatomic) IBOutlet UISwitch *outputSwitch3;
@property (weak,nonatomic) IBOutlet UISwitch *outputSwitch4;
@property (weak,nonatomic) IBOutlet UISwitch *outputSwitch5;
@property (weak,nonatomic) IBOutlet UISwitch *outputSwitch6;
@property (weak,nonatomic) IBOutlet UISwitch *outputSwitch7;
@property (weak,nonatomic) IBOutlet UISwitch *inputSwitch0;
@property (weak,nonatomic) IBOutlet UISwitch *inputSwitch1;
@property (weak,nonatomic) IBOutlet UISwitch *inputSwitch2;
@property (weak,nonatomic) IBOutlet UISwitch *inputSwitch3;
@property (weak,nonatomic) IBOutlet UISwitch *inputSwitch4;
@property (weak,nonatomic) IBOutlet UISwitch *inputSwitch5;
@property (weak,nonatomic) IBOutlet UISwitch *inputSwitch6;
@property (weak,nonatomic) IBOutlet UISwitch *inputSwitch7;
- (IBAction)resetCounter:(UIButton *)sender;
- (IBAction)outputChanged:(UISwitch *)sender;
- (IBAction)liveChanged:(UISwitch *)sender;
@end
@implementation DigitalVC
int counter = 0;
//////////////////////////////
#pragma mark View Lifecycle
//////////////////////////////
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"Digital VC loaded");
switchArrayIn = @[self.inputSwitch0,
self.inputSwitch1,
self.inputSwitch2,
self.inputSwitch3,
self.inputSwitch4,
self.inputSwitch5,
self.inputSwitch6,
self.inputSwitch7];
switchArrayOut = @[self.outputSwitch0,
self.outputSwitch1,
self.outputSwitch2,
self.outputSwitch3,
self.outputSwitch4,
self.outputSwitch5,
self.outputSwitch6,
self.outputSwitch7,];
// Register for notifications
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(boardNotifications:)
name:CONNECTED_NOTIFICATION
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(boardNotifications:)
name:DISCONNECTED_NOTIFICATION
object:nil];
_manager = [NCBoardManager sharedBoardManager];
// Set up callbacks
__unsafe_unretained DigitalVC *digitalVC = self;
[_manager setDigitalInputHandling:dispatch_get_main_queue()
filter:^(NCDigitalInput *input){ return YES; }
handler:^(NCDigitalInput *input){ [digitalVC setInput:input]; }];
appDelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate];
custom1 = [UIColor whiteColor];
custom2 = [UIColor darkGrayColor];
custom3 = [UIColor blackColor];
custom4 = [UIColor colorWithRed:.97 green:.97 blue:.588 alpha:1.0];
CAGradientLayer *gradient = [CAGradientLayer layer];
gradient.frame = self.view.bounds;
gradient.colors = [NSArray arrayWithObjects:(id)[custom2 CGColor], (id)[custom1 CGColor], (id)[custom2 CGColor], nil];
gradient.startPoint = CGPointMake(0.5, 0);
gradient.endPoint = CGPointMake(0.5, 1.0);
gradient.locations = [NSArray arrayWithObjects: [NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:0.5], [NSNumber numberWithFloat:1.0], nil];
[self.view.layer insertSublayer:gradient atIndex:0];
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
[self updateInput];
[self updateOutput];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:FALSE];
[self setColors];
[self setOutputSwitches];
}
图像:
https://www.dropbox.com/s/rh5pwc5ocs0du76/Screenshot%202014-02-26%2009.47.10.png
答案 0 :(得分:2)
选择所有自动调整大小的视觉选项有效并修复了我的问题。我不知道为什么(框中的红线为你缩放视图)
答案 1 :(得分:0)
取消选中IB的UIView和UIScrollview的useAutoLayout和autoResizeSubviews,然后尝试