This is a UIAlertView that has a button linking to this website. It implements the UIAlertView delegate on self.

UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"About"
                                                    message:@"Application developed by Kevin Yavno\n\nVersion 1.0"
                                                   delegate:self
                                          cancelButtonTitle:@"OK"
                                          otherButtonTitles:@"Website",nil];
    [alert show];
}

This is the implementation of the UIAlertViewDelegate. It’s not the best practice to compare the button title to a hardcoded string, but it gets the job done in this simple app.

- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex
{
    NSString *title = [alertView buttonTitleAtIndex:buttonIndex];
    if([title isEqualToString:@"Website"])
    {
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString: @"http://kevinyavno.com"]];
    }
}

Here is an example of how to present iOS’s built in Tweet Compose View. This code simple allocs the view controller, then sets the initial text. After setting the completion handler using a closure (lambda function if you want to get technical) it then finally presents it overtop of our current view.

You need to link the Twitter.framework library with your source to use this code.

Continue reading