@interface ShopController ()<UIWebViewDelegate>
@property (nonatomic,retain) UIView *view;
@property (nonatomic,strong) UIWebView *webView;
@end
@implementation ShopController
//设置下面TabBar的图标和标题以及tag。
-(id)init
{
if (self=[super init]) {
self.tabBarItem=[[UITabBarItem alloc]initWithTitle:@"商城" image:[UIImage imageNamed:@"money.png"] tag:2];
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
self.view.backgroundColor=[UIColor whiteColor];
//设置NavigationItem上面的标题。
self.navigationItem.title=@"网上商城";
self.webView=[[UIWebView alloc]initWithFrame:CGRectMake(0, 0, self.view.bounds.size.width, self.view.bounds.size.height)];
//设置设个界面的WebView的delegate就是这个界面本身。
self.webView.delegate=self;
NSURL *url = [NSURL URLWithString: @"http://192.168.1.171/opencart/index.php?route=account/login"];
NSString *body = [NSString stringWithFormat:@"email=%@&password=%@",@"13715202924",@"Abcd1234"];
NSMutableURLRequest *request = [[NSMutableURLRequest alloc]initWithURL: url];
[request setHTTPMethod: @"POST"];
[request setHTTPBody: [body dataUsingEncoding: NSUTF8StringEncoding]];
[self.webView loadRequest: request];
[self.view addSubview:self.webView];
}
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
return YES;
}
@end