滚动视图在编译时不滚动

时间:2014-01-28 23:17:58

标签: ios iphone objective-c uiscrollview

我有以下应用程序,我已经实现了滚动视图(图像概述了故事板上的层次结构:e

Hierarchy of storyboard

我已关闭自动布局,因为这里的严重帖子似乎表明这会产生问题。

这是我的.h文件:

#import <UIKit/UIKit.h>
#import <MessageUI/MessageUI.h>
#import <MessageUI/MFMailComposeViewController.h>
#import <AssetsLibrary/ALAsset.h>
#import <AssetsLibrary/ALAssetRepresentation.h>
#import <ImageIO/CGImageSource.h>
#import <ImageIO/CGImageProperties.h>
#import <CoreLocation/CoreLocation.h>



@interface DobInAHoonViewController : UIViewController<UIImagePickerControllerDelegate, UINavigationControllerDelegate, MFMailComposeViewControllerDelegate, UITextFieldDelegate, CLLocationManagerDelegate>
{
    IBOutlet UIPickerView *vehiclePickerView;
    UIImagePickerController *picker1;
    UIImagePickerController *picker2;
    UIImage *image;
    IBOutlet UIImageView *imageView;
    CLLocationManager *locationManager;
    CGFloat animatedDistance;

}
@property (strong, nonatomic) IBOutlet UIImageView *BackgroundImage;
@property (strong, nonatomic) IBOutlet UIScrollView *scrollView;
@property (strong, nonatomic) NSString *Latitude;
@property (strong, nonatomic) NSString *longditute;
@property  (strong, nonatomic) NSArray *toRecipients;
@property (strong, nonatomic) ALAssetsLibrary *assetsLibrary;
@property (strong, nonatomic) NSMutableArray *groups;


@property (nonatomic, retain) IBOutlet UITextField *vehilceMake;
@property (nonatomic, retain) IBOutlet UITextField *vehilceColour;
@property (nonatomic, retain) IBOutlet UITextField *regoNumber;
@property (nonatomic, retain) IBOutlet UITextField *location;
@property (nonatomic, retain) IBOutlet UITextField *additionalInfo;
@property (nonatomic, retain) IBOutlet UITextField *vehicleType;


- (IBAction)takePhoto;
-(IBAction)chooseExisting;
-(IBAction)actionEmailComposer;
-(IBAction)textFileReturn:(id)sender;
-(IBAction)DismissKeyboard:(id)sender;
@end

和我的.m文件:

#import "DobInAHoonViewController.h"

@interface DobInAHoonViewController ()



@end

@implementation DobInAHoonViewController
@synthesize BackgroundImage;
@synthesize vehilceColour;
@synthesize vehilceMake;
@synthesize regoNumber;
@synthesize Latitude;
@synthesize location;
@synthesize longditute;
@synthesize additionalInfo;
@synthesize toRecipients;
@synthesize assetsLibrary;
@synthesize groups;
@synthesize vehicleType;
@synthesize scrollView;



static const CGFloat KEYBOARD_ANIMATION_DURATION = 0.3;
static const CGFloat MINIMUM_SCROLL_FRACTION = 0.2;
static const CGFloat MAXIMUM_SCROLLFRACTION = 0.8;
static const CGFloat PORTRAIT_KEYBOARD_HEIGHT = 216;
static const CGFloat LANDSCAPE_KEYBOARD_HEIGHT = 140;




-(BOOL)textFieldShouldReturn:(UITextField *)textField
{
    [vehilceMake resignFirstResponder];
    [vehilceMake resignFirstResponder];
    [vehilceColour resignFirstResponder];
    [location resignFirstResponder];
    [additionalInfo resignFirstResponder];
    [regoNumber resignFirstResponder];
    return YES;
}


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}






- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view.

    [self.scrollView setScrollEnabled:YES];
    [self.scrollView setContentSize:(CGSizeMake(320, 1000))];


    locationManager = [[CLLocationManager alloc]init];
    toRecipients = [[NSArray alloc]initWithObjects:@"scott.boon@shellharbour.nsw.gov.au", nil];

    BackgroundImage.alpha = 0.3;
    static int emergAlertCounter;
    if (emergAlertCounter <1) {


    UIAlertView *emergencyAlert = [[UIAlertView alloc]
                               initWithTitle:@"NOTE" message:@"Do not endanger your life to dob in a hoon. If your life is threatened, or you are reporting an emergency situation, exit this app and dial '000' IMMEDIATLY!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
    [emergencyAlert show];
        emergAlertCounter = emergAlertCounter+1;
    }
}

由于某种原因,当我运行应用程序时,滚动视图不滚动。我已将属性设置为在界面构建器中滚动。

任何建议都将不胜感激。

1 个答案:

答案 0 :(得分:1)

您必须确保滚动视图小于320 x 1000并且嵌入视图大于320 x 1000