English 中文(简体)
如何在纽特州点击事件采取行动时,按观察载荷数据进行点击
原标题:how to call under viewdid load data when button click event action is done

我正在发展观点应用。 我有这样的方法:即(国际行动)把这种方法放到点击事件行动。 现在,当我们点击纽顿时,它就应当装满负荷,而它不是装满负荷,那么,没有人能够就此提供帮助。

-(IBAction)switchPage:(id)sender

    {
    if(self.viewTwoController == nil)
    {
        ViewTwoController *viewTwo = [[ViewTwoController alloc]
                                      initWithNibName:@"View2" bundle:[NSBundle mainBundle]];
        self.viewTwoController = viewTwo;
        [viewTwo release];
    }
  [self.navigationController pushViewController:self.viewTwoController animated:YES];

[connection release];
}
//in viw did load i have this code 

- (void)viewDidLoad {
    [super viewDidLoad];

    responseData = [[NSMutableData data] retain];
    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"http://108.16.210.28/Account/LogOn"]];
    [[NSURLConnection alloc] initWithRequest:request delegate:self];
}

- (void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response {
    [responseData setLength:0];
}

- (void)connection:(NSURLConnection *)connection didReceiveData:(NSData *)data {
    [responseData appendData:data];
}

- (void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error {
//  label.text = [NSString stringWithFormat:@"Connection failed: %@", [error description]];
}

- (void)connectionDidFinishLoading:(NSURLConnection *)connection {
    [connection release];
    NSString *post =[[NSString alloc] initWithFormat:@"usernameField=%@&passwordField=%@",usernameField.text,passwordField.text];
    NSURL *url=[NSURL URLWithString:@"https://108.16.210.28/SSLLogin/Account/LogOn"];

    NSLog(post);
    NSData *postData = [post dataUsingEncoding:NSASCIIStringEncoding allowLossyConversion:YES];

    NSString *postLength = [NSString stringWithFormat:@"%d", [postData length]];

    NSMutableURLRequest *request = [[[NSMutableURLRequest alloc] init] autorelease];
    [request setURL:url];
    [request setHTTPMethod:@"POST"];
    [request setValue:postLength forHTTPHeaderField:@"Content-Length"];
    [request setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"Content-Type"];
    [request setHTTPBody:postData];

    /* when we user https, we need to allow any HTTPS cerificates, so add the one line code,to tell teh NSURLRequest to accept any https certificate, i m not sure about the security aspects
     */

    [NSURLRequest setAllowsAnyHTTPSCertificate:YES forHost:[url host]];

    NSError *error;
    NSURLResponse *response;
    NSData *urlData=[NSURLConnection sendSynchronousRequest:request returningResponse:&response error:&error];

    NSString *data=[[NSString alloc]initWithData:urlData encoding:NSUTF8StringEncoding];
    NSLog(@"%@",data);
}

加入

问题回答

作为优化,国家航空通信公司直到最后一刻,即实际接触到这些观点时,才有自己的意见。 因此,在新版和制版后,将立即装上<条码>。 将采用这种方法。

Edit: 你的法典希望:

-(IBAction)switchPage:(id)sender {
    if(self.viewTwoController == nil) {

        ViewTwoController *viewTwo = [[ViewTwoController alloc]
            initWithNibName:@"View2" bundle:[NSBundle mainBundle]];
        self.viewTwoController = viewTwo;
        [viewTwo release];
        [viewTwo view]    // calls loadView, loads the nib then calls viewDidLoad
iii
[self.navigationController pushViewController:self.viewTwoController animated:YES];
[connection release];

iii





相关问题
How to change out-of-focus text selection color in Xcode?

Okay, I ll bite. I ve got really pleasant code/window colors set up in Xcode. Ordinarily, my selection color is very visible. When I am doing a project search and iterating through the results, ...

Iphone NSTimer Issue

Hi I am new to objective c. I am trying to make an app for iphone. I have a button on my view, and the click on which the function playSound is called. This is working properly. It does plays the ...

Include a .txt file in a .h in C++?

I have a number of places where I need to re-use some template code. Many classes need these items In a .h could I do something like: #include <xxx.txt> and place all of this code in the ....

Iterating over string/strlen with umlauted characters

This is a follow-up to my previous question . I succeeded in implementing the algorithm for checking umlauted characters. The next problem comes from iterating over all characters in a string. I do ...

Xcode open two editor windows with same file

Is it possible to open the same file in two separate windows in Xcode. I can open a file in one window and the same file in the main Xcode editor window, but I wanted two separate fulltime editor ...

Forcing code signing refresh in Xcode

In our environment, we share resources across multiple projects and platforms. When building for iPhone, only a subset of those resources are needed. Since that subset is still considerable, we have ...

热门标签