开发者

How to connect web url in iphone application development?

I am new to iphone ap开发者_JAVA技巧plication.I have 6 uiimages in a view.fifth image is facebook and sixth one is twiter.Under images,Iplaced two roundrectbuttons named as click5 and click6. My requirement is,when i click on those images,I have to go to login pages of facebook and twitter.how can i do this?can anyone send me sample example and explain it detai?


If you want to send the user to the website using Safari, you invoke the openURL: method in the UIApplication class, like this:

NSURL *facebookURL = [NSURL URLWithString:@"http://www.facebook.com"];
[[UIApplication sharedApplication] openURL:facebookURL];

When assigning a button to an action, you use the UIButton's addTarget:action:forControlEvents:, providing an event handler as action. Say you're setting this up in viewDidLoad, it might look like this:

- (void) viewDidLoad {
    [myButton addTarget:self 
                 action:@selector(btnClicked:) 
       forControlEvents:UIControlEventTouchUpInside];
}

/**
 * Click/tap event handler for some buttons
 */
- (IBAction) btnClicked:(id)sender {

    // Check which button was pressed.
    if (sender == self.click5) {
        // ...
    }
    else if (sender == self.click6) {
        // ...
    }
}


You know the very easiest way to do this? With the free 3rd party component ShareKit. It wraps the Facebook and Twitter (and several other social network) APIs to literally make it a three-line deal to post things.

I used it for the first time in the last app I built and I was SHOCKED at how easy to use it was.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜