2

私はUIView(もちろんView Controllerの中に)を持っており、このUIView中にはUIScrollView. UIScrollViewいくつかの画像とボタンが含まれています。UIViewボタンの 1 つはモーダル アクション セグエを使用し、内側にが開きMapView、下部にある「戻る」ボタンで前の に戻りますUIViewMapViewしかし、( からにUIView) 「戻る」と、 MapView に戻って戻る前のようにUIScrollView スクロールしなくなります。上の位置でロックされているようです。デリゲートと何か関係があるような気がしますか?わかりませんが、それらについてはまだはっきりしていません。とにかく、スクロールの問題に対する洞察はありますか?? ありがとう!!

これが私の .h ファイルです (私のスクロールビューがある場所):

#import <UIKit/UIKit.h>
#import <QuartzCore/QuartzCore.h>

@interface ThirdViewController : UIViewController <UIScrollViewDelegate, UIScrollViewAccessibilityDelegate>

@property (strong, nonatomic) IBOutlet UIView *findUsView;
@property (weak, nonatomic) IBOutlet UIScrollView *findUsScrollView;
- (IBAction)callButton:(id)sender;
- (IBAction)getDirButton:(id)sender;

@end

ここに私の .m ファイルがあります(私のスクロールビューがある場所):

#import "ThirdViewController.h"

@implementation ThirdViewController

- (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.view.backgroundColor = [UIColor colorWithPatternImage:[UIImage imageNamed:@"appBackgroundColor.png"]];

    [self.view addSubview:self.findUsScrollView];
}

-(void)viewWillAppear:(BOOL)animated{

    //this line creates the frame of the scrollview (dimensions)
    [self.findUsScrollView setFrame:CGRectMake(0, 0, 0, 750)];
    [super viewWillAppear:animated];
}

-(void)viewDidAppear:(BOOL)animated
{
    //dimensions of content within scrollveiw. Scrolling enabaled.
    [self.findUsScrollView setScrollEnabled:YES];
    [self.findUsScrollView setContentSize:CGSizeMake(0, 751)];
    [super viewWillAppear:animated];
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (IBAction)callButton:(id)sender {

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:@"tel:0000000000"]];
}

- (IBAction)getDirButton:(id)sender {

}

@end

マップ ビューの .h ファイルは次のとおりです。

#import <UIKit/UIKit.h>
#import <MapKit/MapKit.h>

@interface MyMapViewController : UIViewController <MKMapViewDelegate, MKAnnotation>

@property (weak, nonatomic) IBOutlet MKMapView *mapView;
@property (weak, nonatomic) IBOutlet UINavigationBar *titleBarMap;
@property (weak, nonatomic) IBOutlet UIToolbar *bottomNavBarMap;
@property (weak, nonatomic) IBOutlet UIView *topTitlesOverlay;
- (IBAction)backButtonMap:(id)sender;

@end

マップ ビューの .m ファイルは次のとおりです。

#import "MyMapViewController.h"

@implementation BountMapViewController

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

- (IBAction)backButtonMap:(id)sender {

    [self dismissViewControllerAnimated:YES completion: ^(void){
    ThirdViewController *vc = (ThirdViewController *)[self presentingViewController];
    [[vc findUsScrollView] becomeFirstResponder];

}];
}

@end
4

2 に答える 2

0

Try moving [self.findUsScrollView setFrame:CGRectMake(0, 172, 320, 680)]; and [self.findUsScrollView setContentSize:CGSizeMake(320, 680)]; to viewDidLoad as a first suggestion. You don't want those to be called everytime your view appears.

Second, your contentSize and frameSize are the same (320, 680). This means your UIScrollView does not need to scroll. Remember: for a UIScrollView to scroll it's content size must be bigger than it's frame size. That should be all, and of course: setScrollEnabled: YES;

于 2012-11-30T01:29:16.387 に答える
0

あなたのオーバーライドはの代わりにviewDidAppear呼び出しています[super viewWillAppear:][super viewDidAppear:]

于 2012-11-30T06:55:12.997 に答える