ipad开发

设备选择为: ipad




AppDelegate.h


AppDelegate.m

RootableviewController.m


#import "RooTableViewCotntroller.h"

#import "AppDelegate.h"

#import "DetailViewController.h"

@interface RooTableViewCotntroller ()

@property(nonatomic,strong)NSArray* imgTitleArr;

@property(nonatomic,strong)NSArray* imgArr;

@end

@implementation RooTableViewCotntroller

- (void)viewDidLoad {

[super viewDidLoad];

self.imgTitleArr = @[@"**",@"**",@"**",@"**",@"**",@"**",@"**"];

NSMutableArray* arr = [[NSMutableArray alloc]init];

for (int i = 1; i <= 7; i++)

{

NSString *imgName = [NSString stringWithFormat:@"car%d.jpg",i];

UIImage* img = [UIImage imageNamed:imgName];

[arr addObject:img];

}

self.imgArr = [arr copy];

}

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

return 1;

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

return self.imgArr.count;

}

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath

{

static NSString *identifier = @"cell";

UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:identifier];

if (cell == nil)

{

cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];

}

cell.textLabel.text = self.imgTitleArr[indexPath.row];

return  cell;

}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath

{

AppDelegate* appDelegate = (AppDelegate*)[UIApplication sharedApplication].delegate;

DetailViewController *detaiVC = appDelegate.detailVC;

detaiVC.mapView.image = self.imgArr[indexPath.row];

}



DetailViewController.h

DetailViewController.m


#import "DetailViewController.h"

#import "AppDelegate.h"

#import "RooTableViewCotntroller.h"

@interface DetailViewController ()<UIPopoverControllerDelegate>

@end

@implementation DetailViewController

- (void)viewDidLoad {

[super viewDidLoad];

self.navigationItem.rightBarButtonItem = [[UIBarButtonItem alloc]initWithTitle:@"主菜单" style:UIBarButtonItemStylePlain target:self action:@selector(click:)];

AppDelegate* app = (AppDelegate*)[UIApplication sharedApplication].delegate;

app.spiltVC.displayModeButtonItem.title = @"显示导航栏";

self.navigationItem.leftBarButtonItem  = app.spiltVC.displayModeButtonItem;

}

-(void)click:(UIBarButtonItem* )sender

{

RooTableViewCotntroller* rootVC = [[RooTableViewCotntroller alloc]initWithStyle:UITableViewStylePlain];

UIPopoverController* popCtl = [[UIPopoverController alloc]initWithContentViewController:rootVC];

popCtl.popoverContentSize = CGSizeMake(200, 300);

popCtl.backgroundColor = [UIColor yellowColor];

popCtl.delegate = self;

[popCtl presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

}

-(BOOL)popoverControllerShouldDismissPopover:(UIPopoverController *)popoverController

{

return YES;

}

-(void)splitViewController:(UISplitViewController *)svc willChangeToDisplayMode:(UISplitViewControllerDisplayMode)displayMode

{

// 左侧导航栏隐藏

if (displayMode == UISplitViewControllerDisplayModePrimaryHidden)

{

NSLog(@"左侧导航将要隐藏");

AppDelegate *app = (AppDelegate*)[UIApplication sharedApplication].delegate;

app.spiltVC.displayModeButtonItem.title = @"显示导航栏";

//

svc.displayModeButtonItem.title = @"显示导航栏";

self.navigationItem.leftBarButtonItem = app.spiltVC.displayModeButtonItem;

}

else if (displayMode == UISplitViewControllerDisplayModePrimaryOverlay)

{

NSLog(@"左侧导航覆盖到详情视图上");

}

else if (displayMode == UISplitViewControllerDisplayModeAllVisible)

{

NSLog(@"左侧导航全部显示");

self.navigationItem.leftBarButtonItem = nil;

}

else

{

NSLog(@"自动显示");

}

}




最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 创建一个继承于UITableViewController的控制器和继承于UIViewController(绑定xi...
    Whimer阅读 687评论 0 1
  • //联系人:石虎QQ: 1224614774昵称:嗡嘛呢叭咪哄 /**注意点: 1.看 GIF 效果图.2.看连线...
    石虎132阅读 2,374评论 0 9
  • 作者唯一QQ:228544117。。。。。 =========后面的都要新建一个文章 AppDelegate.h ...
    CC_iOS阅读 1,014评论 0 0
  • 概述在iOS开发中UITableView可以说是使用最广泛的控件,我们平时使用的软件中到处都可以看到它的影子,类似...
    liudhkk阅读 9,118评论 3 38
  • 躲在“爱孩子”背后的开放式婚姻 白百合出轨的事情发酵到现在,各种观点都有。 有说出轨好的,“凭什么林丹出轨可以原谅...
    陈妍妈妈阅读 672评论 2 5