0
我得到了一個問題,現在正在進行一個星期,我有一個webView,我設置了,但xib文件不想與我的控制器鏈接,我知道有一個話題關於這一點,但我是新的目標C和我不明白一個該死的事情,我寧願要以編程方式做,如果有人可以告訴我或請幫助我。Xib文件鏈接和WebViews
這裏是我的代碼:
.H #進口
@interface ViewController : UIViewController <UIWebViewDelegate>
{
IBOutlet UIWebView *myWebView;
}
@property (nonatomic, retain) IBOutlet UIWebView *myWebView;
-(void)PushView;
@end
.M
#import "MyWebViewController.h"
@interface ViewController()
@end
@implementation ViewController
@synthesize myWebView = _myWebview;
-(void)viewDidLoad;
{
myWebView = [[UIWebView alloc] initWithFrame:self.view.frame];
myWebView.delegate = self;
NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
NSString *defaults = [prefs stringForKey:@"myKey"];
NSString *defaults2 = [prefs stringForKey:@"mySecondKey"];
NSString *username = defaults;
NSString *password = defaults2;
NSLog(defaults);
NSURL* url = [NSURL URLWithString:@"http://www.google.com"];
NSString* body = [NSString stringWithFormat:@"login=%@&password=%@", username, password];
NSMutableURLRequest* request = [NSMutableURLRequest requestWithURL:url cachePolicy:NSURLRequestReloadIgnoringLocalAndRemoteCacheData timeoutInterval:30];
request.HTTPMethod = @"POST";
request.HTTPBody = [body dataUsingEncoding:NSStringEncodingConversionAllowLossy];
[myWebView loadRequest:request];
[super viewDidLoad];
}
@end
現在就像一個魅力,謝謝先生! :d –