模态对话框

#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];

}



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值