日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

IOS UINavigationController use

發布時間:2025/5/22 编程问答 19 豆豆
生活随笔 收集整理的這篇文章主要介紹了 IOS UINavigationController use 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.


1 appdelegate.h

? 定義屬性:?window,navigationViewController

@interface AppDelegate : UIResponder <UIApplicationDelegate>


@property (strong, nonatomic) UIWindow *window;


@property (strong, nonatomic) UINavigationController *navigationViewController;


@end?

?

2 appdelegate.m

對屬性初始化,窗口初始化


@implementation AppDelegate

@synthesize window=_window;

@synthesize navigationViewController=_navigationViewController;


- (void)dealloc

{

? ? [_window release];

? ? [_navigationViewController release];

? ? [super dealloc];

}


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

? ? self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];

? ? // Override point for customization after application launch.

?? ?

? ? RootViewController* rootViewController=[[[RootViewController alloc] initWithNibName:@"RootViewController" bundle:nil] autorelease];

?? ?

? ? self.navigationViewController=[[[UINavigationController alloc] initWithRootViewController:rootViewController] autorelease];

?

? ? self.window.rootViewController = self.navigationViewController;

? ? [self.window makeKeyAndVisible];

? ? return YES;

}?

?

3?RootViewController.h 初始化加載數據到tabveiwController

- (void)viewDidLoad

{

? ? [super viewDidLoad];


? ? // Uncomment the following line to preserve selection between presentations.

? ? // self.clearsSelectionOnViewWillAppear = NO;

?

? ? // Uncomment the following line to display an Edit button in the navigation bar for this view controller.

? ? // self.navigationItem.rightBarButtonItem = self.editButtonItem;

? ? self.categary=[NSArray arrayWithObjects:@"11",@"22",@"33",@"44", nil];

? ? self.title=@"sina wei bo";

}


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView

{

? ? // Return the number of sections.

? ? return 1;

}


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

{

? ? // Return the number of rows in the section.

? ? return [self.categary count];

}


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

{

? ? static NSString *CellIdentifier = @"Cell";

? ? UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];

?? ?

? ? // Configure the cell...

? ? if (cell==nil) {

? ? ? ? cell=[[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];

? ? }

? ? cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

? ? cell.textLabel.text=[self.categary objectAtIndex:indexPath.row];

? ? cell.accessoryType=UITableViewCellAccessoryDisclosureIndicator;

? ? return cell;

}

?

點擊一個CELL,跳轉到下一窗口

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

{

? ? // Navigation logic may go here. Create and push another view controller.

? ? /*

?? ? <#DetailViewController#> *detailViewController = [[<#DetailViewController#> alloc] initWithNibName:@"<#Nib name#>" bundle:nil];

?? ? // ...

?? ? // Pass the selected object to the new view controller.

?? ? [self.navigationController pushViewController:detailViewController animated:YES];

?? ? [detailViewController release];

?? ? */

? ? SubViewController *subViewController=[[SubViewController alloc] initWithNibName:@"SubViewController" bundle:nil];

?? ?

? ? [self.navigationController pushViewController:subViewController animated:YES];

? ? [SubViewController release];

}

?

轉載于:https://www.cnblogs.com/csj007523/archive/2012/08/16/2643223.html

總結

以上是生活随笔為你收集整理的IOS UINavigationController use的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。