我遇到了一个持续一周的问题,我设置了一个 webView,但是 xib 文件不想与我的控制器链接,我知道有一个关于这个的话题,但我是新手目标c,我什么都不懂,如果有人可以向我展示或帮助我,我宁愿以编程方式进行。
这是我的代码:
.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];
}
@结尾