模态对话框

来源:互联网 发布:童装店收银软件 编辑:程序博客网 时间:2024/05/29 10:15

#import <UIKit/UIKit.h>


@protocol ModalWebViewControllerDelegate;


@interface ModalWebViewController : UIViewController{

id <ModalWebViewControllerDelegate> delegate;

UIWebView *webView;

}

@property (nonatomic,assign) id<ModalWebViewControllerDelegate> delegate;

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


-(IBAction)done;

-(IBAction)contact;


@end


@protocol ModalWebViewControllerDelegate

-(void)modalWebViewControllerDidFinish:(ModalWebViewController *)controller;

@end


//以上为代理的协议与模态对话框类的定义


    //

//  ModalWebViewController.m

//  Browser

//

//  Created by 姜ww on 11-7-18.

//  Copyright 2011 njau. All rights reserved.

//


#import "ModalWebViewController.h"



@implementation ModalWebViewController

@synthesize delegate;

@synthesize webView;

 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.

/*

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {

    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

    if (self) {

        // Custom initialization.

    }

    return self;

}

*/



// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.

- (void)viewDidLoad {

NSString *path = [[NSBundle mainBundle] pathForResource:@"OurInfo" ofType:@"html"];

NSURL *url=[NSURL fileURLWithPath:path];

NSURLRequest *request = [NSURLRequest requestWithURL:url];


//webView.delegate=self;

//NSString *path = @"http://www.baidu.com";



//[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:path]]];

[self.webView loadRequest:request]; 

    [super viewDidLoad];

}




- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {

    // Overriden to allow any orientation.

    return YES;

}



- (void)didReceiveMemoryWarning {

    // Releases the view if it doesn't have a superview.

    [super didReceiveMemoryWarning];

    

    // Release any cached data, images, etc. that aren't in use.

}



- (void)viewDidUnload {

    [super viewDidUnload];

    // Release any retained subviews of the main view.

    // e.g. self.myOutlet = nil;

}


-(IBAction)done{

[self.delegate modalWebViewControllerDidFinish:self];

}


-(IBAction)contact{

NSLog(@"contact us!");

}


- (void)dealloc {

[webView release];

    [super dealloc];

}


/*

- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType{

NSLog(@"Web begin!");

}


- (void)webViewDidStartLoad:(UIWebView *)webView{

NSLog(@"Web begin!");

}

- (void)webViewDidFinishLoad:(UIWebView *)webView{

NSLog(@"Web done!");

}

*/

@end






//以上为嵌入本地网页的显示出模态对话框的.m文件内容

-(IBAction) test{

ModalWebViewController * controller = [[[ModalWebViewController alloc] initWithNibName:@"ModalWebViewController" bundle:nil] autorelease];

controller.delegate=self;

controller.modalPresentationStyle=UIModalPresentationFormSheet;

[self presentModalViewController:controller animated:YES];

}



原创粉丝点击