XibDemo

//
//  MyviewViewController.h
//  XibDemo
//
//  Created by hehe on 15/9/21.
//  Copyright (c) 2015年 wang.hehe. All rights reserved.
//

#import <UIKit/UIKit.h>

@interface MyviewViewController : UIViewController

@property (weak, nonatomic) IBOutlet UIButton *Go;

- (IBAction)onclic:(id)sender;

@property (weak, nonatomic) IBOutlet UITextField *textfield1;

@property (weak, nonatomic) IBOutlet UIWebView *web;
@end


//
//  MyviewViewController.m
//  XibDemo
//
//  Created by hehe on 15/9/21.
//  Copyright (c) 2015年 wang.hehe. All rights reserved.
//

#import "MyviewViewController.h"

@interface MyviewViewController ()

@end

@implementation MyviewViewController

- (void)viewDidLoad {
    [super viewDidLoad];


     
}



- (IBAction)onclic:(id)sender {
    
    NSURL *url = [NSURL URLWithString:_textfield1.text];
    
    NSURLRequest *request = [NSURLRequest requestWithURL:url];
    
    [_web loadRequest:request];
    
    [_textfield1 resignFirstResponder];
}
@end



//在appdelegate中的代码

//
//  AppDelegate.m
//  XibDemo
//
//  Created by qianfeng on 15/9/21.
//  Copyright (c) 2015年 qianfeng. All rights reserved.
//

#import "AppDelegate.h"
#import "MyviewViewController.h"

@interface AppDelegate ()

@end

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds] ];
    self.window.backgroundColor = [UIColor whiteColor];
    
    //    ViewController *vc = [[ViewController alloc]init];
    MyviewViewController *vc = [[MyviewViewController alloc] initWithNibName:@"MyviewViewController" bundle:nil];
    
    self.window.rootViewController = vc;
    [self.window makeKeyAndVisible];
    
    return YES;
}


@end

 

posted @ 2015-09-21 22:11  阿凡提王  阅读(149)  评论(0编辑  收藏  举报