0

私は一般的にプログラミングに比較的慣れていませんが、これに対する答えを見つけようとしましたが、終わりがありませんでした。

したがって、基本的には、マップ ビュー シーンを持つアプリケーションを作成しようとしていますが、それは正常に機能します。次に、Web ビュー用の別のシーンがあります。そのため、mapview シーンに移動すると、webview シーンに移動するボタンがあります。

ただし、webview シーンは web ページをまったくロードしていませんが、アプリケーションの webview 部分を他のコーディングを伴わずに別のプロジェクトで作成すると、問題なく動作します。

これが私がこれまでに持っているコーディングです:

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

@interface ViewController : UIViewController {
    MKMapView * mapview; IBOutlet UIWebView *webview;
}

@property (nonatomic, retain) IBOutlet UIWebView*webview;

@property (nonatomic, retain) IBOutlet MKMapView *mapview;
-(IBAction)setMap:(id)sender;
-(IBAction)getlocation;



@end

--------


@implementation ViewController

@synthesize webview;
@synthesize mapview;


-(IBAction) getlocation {
    mapview.showsUserLocation= YES;
}

-(IBAction)setMap:(id)sender {
    switch(((UISegmentedControl *) sender).selectedSegmentIndex) {
        case 0:
            mapview.mapType= MKMapTypeStandard;
            break;
        case 1:
            mapview.mapType= MKMapTypeSatellite;
            break;
        case 2:
            mapview.mapType= MKMapTypeHybrid;
            break;

        default:
            break;



    }




}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Release any cached data, images, etc that aren't in use.
}

#pragma mark - View lifecycle

- (void)viewDidLoad 
{
    [super viewDidLoad];
    [webview loadRequest:[NSURLRequest requestWithURL: [NSURL URLWithString: @"http://www.google.com"]]];
    // Do any additional setup after loading the view, typically from a nib.
}

お役に立てれば幸いです。精緻化が必要な場合はお知らせください。

4

3 に答える 3

0

Web ビューの委任方法を確認してください

[webview setDelegate:self];
于 2013-05-13T04:53:09.363 に答える
0

プログラムで webView を作成します。

viewDidLoad に追加:

UIWebView *webView = [[UIWebView alloc] initWithFrame:self.view.bounds];

[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://google.co.uk"]]];
                 [self.view addSubview:webView];
于 2013-05-12T23:33:06.427 に答える