Я делаю приложение для iPad Master-Detail в раскадровке с ios5.
Я создаю таблицу с NSURL.
Мой вопрос и помощь в том, что я хочу иметь индикатор активности для NSURL, поэтомучто, когда я нажимаю на ячейку в табличном представлении, он показывает индикатор активности, когда страница загружается, а когда завершает, индикатор активности отменяется.
Это мой код в MAsterViewController:
#import "MasterViewController.h"
#import "DetailViewController.h"
@interface MasterViewController (PrivateMethods)
-(void)LocateArtistPageInSafari;
-(void)LocateArtist2PageInSafari;
-(void)LocateArtist3PageInSafari;
-(void)DeselectRow;
@end
@implementation MasterViewController
@synthesize detailViewController = _detailViewController;
- (void)awakeFromNib
{
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
self.clearsSelectionOnViewWillAppear = NO;
self.contentSizeForViewInPopover = CGSizeMake(320.0, 600.0);
}
[super awakeFromNib];
}
- (void)dealloc
{
[_detailViewController release];
[super dealloc];
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Release any cached data, images, etc that aren't in use.
}
#pragma mark - View lifecycle
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
self.detailViewController = (DetailViewController *)[[self.splitViewController.viewControllers lastObject] topViewController];
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
[self.tableView selectRowAtIndexPath:[NSIndexPath indexPathForRow:0 inSection:0] animated:NO scrollPosition:UITableViewScrollPositionMiddle];
self.detailViewController.webView.delegate = self;
}
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
// e.g. self.myOutlet = nil;
}
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
}
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
}
- (void)viewWillDisappear:(BOOL)animated
{
[super viewWillDisappear:animated];
}
- (void)viewDidDisappear:(BOOL)animated
{
[super viewDidDisappear:animated];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// Return YES for supported orientations
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPhone) {
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
} else {
return YES;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSInteger nSelectedRowIdx = indexPath.section *2 + indexPath.row;
switch (nSelectedRowIdx)
{
case 0:
[self LocateArtistPageInSafari];
break;
case 1:
[self LocateArtist2PageInSafari];
break;
case 2:
[self LocateArtist3PageInSafari];
break;
}
//[self DeselectRow];
}
-(void)DeselectRow
{
// Unselect the selected row if any
NSIndexPath* selection = [self.tableView indexPathForSelectedRow];
if (selection) {
[self.tableView deselectRowAtIndexPath:selection animated:YES];
}
[self.tableView reloadData];
}
-(void)LocateArtistPageInSafari
{
NSURL *urlInSafari = [NSURL URLWithString:@"http://interia.pl"];
// if we have an iPAD...
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
// then open page in detail view (UIWebView)
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:urlInSafari];
[self.detailViewController.webView loadRequest:urlRequest];
}
}
-(void)LocateArtist2PageInSafari
{
NSURL *urlInSafari = [NSURL URLWithString:@"http://on.fb.me/nFwQj6"];
// if we have an iPAD...
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
// then open page in detail view (UIWebView)
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:urlInSafari];
[self.detailViewController.webView loadRequest:urlRequest];
}
}
-(void)LocateArtist3PageInSafari
{
NSURL *urlInSafari = [NSURL URLWithString:@"http://bit.ly/nxY8AZ"];
// if we have an iPAD...
if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
// then open page in detail view (UIWebView)
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:urlInSafari];
[self.detailViewController.webView loadRequest:urlRequest];
}
}
@end
Я надеюсь, что кто-нибудь может мне помочь !!!!Большое спасибо