活动指示器与主从应用程序集成
我用 ios5 在故事板中制作了一个 iPad 主从应用程序。
我用 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
我希望有人可以帮助我!!!!多谢
I make an iPad Master-Detail Application in storyboard with ios5.
I make tableview with NSURL.
My question and help is that i want have the activity indicator for NSURL, so that when i click on the cell in the tableview he show the activity indicator when the page are loading and when finish the activity indicator desepear.
This is my code in the 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
I hope somebody can help me!!!! THanks a lot
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论