PPRevealSideViewController第三庫的簡單例子

PPRevealSideViewController第三庫的簡單例子



代碼下載:


http://pan.baidu.com/share/link?shareid=3833108176&uk=3189484501





這個第三方庫是能夠實現左右滑動視圖控制器效果的第三方庫,第三庫在代碼例子中就有的


首先,我們需要再創建一個視圖控制器,讓它直接繼承自UITableViewController

我們不需要額外添加代碼。


AppDelegate.h代碼實現如下:

#import <UIKit/UIKit.h>
#import "PPRevealSideViewController.h"
@class ViewController;
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) ViewController *viewController;
@property (strong, nonatomic) PPRevealSideViewController* revealSideViewController;
@property (strong, nonatomic) UINavigationController* nav;
@end



.m文件實現如下:

我們要在

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions方法添加如下代碼:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
    // Override point for customization after application launch.
                              
    self.viewController = [[[ViewController alloc] initWithNibName:@"ViewController" bundle:nil] autorelease];
                              
    //創建一個導航
    self.nav = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    //初始化一個可以左右劃第三庫的對象
    self.revealSideViewController = [[PPRevealSideViewController alloc] initWithRootViewController:self.nav];
                              
    self.revealSideViewController.panInteractionsWhenClosed = PPRevealSideInteractionContentView|PPRevealSideInteractionNavigationBar;
                              
                              
    self.window.rootViewController = self.revealSideViewController;
//    PP_RELEASE(self.viewController);
//    PP_RELEASE(self.nav);
    [self.window makeKeyAndVisible];
    return YES;
}




ViewController.h代碼實現如下:

#import <UIKit/UIKit.h>
#import "TableViewControllerABC.h"
#import "PPRevealSideViewController.h"
@interface ViewController : UIViewController
@property (strong , nonatomic) TableViewControllerABC* tB;
@end




ViewController.m代碼如下:

-(void)viewWillAppear:(BOOL)animated
{
    self.tB = [[TableViewControllerABC alloc] initWithStyle:UITableViewStylePlain];
    //設置左劃顯示的視圖控制器
    [self.revealSideViewController preloadViewController:self.tB forSide:PPRevealSideDirectionLeft];
    [super viewWillAppear:animated];
}





發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章