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];
}