我在Appdelegate.m中调用SWRevealViewController
SWRevealViewController *svc = self.revealViewController;
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
FrontVC *homeVC = [storyboard instantiateViewControllerWithIdentifier:@"FrontVC"];
[svc setFrontViewController:homeVC animated:NO];
[svc revealToggleAnimated:YES];
但我无法加载FrontVC控制器。 什么是正确的呼叫方式
答案 0 :(得分:2)
对于Swift 2.2
DrawableRequestBuilder<String> builder = Glide.with(ctx).load(...);
if (nsfw) {
builder.bitmapTransform(new BlurTransformation(ctx, 8, 16), new CentreCrop(...));
} else {
builder.centerCrop();
}
builder.listener(new RequestListener<String, GlideDrawable>() {
... //onException method
@Override
public boolean onResourceReady(GlideDrawable resource, String model, Target<GlideDrawable> target, boolean isFromMemoryCache, boolean isFirstResource) {
boolean handled = false;
if (nsfw && resource.isAnimated()) {
target.onResourceReady(new GlideBitmapDrawable(null, ((GifDrawable) resource).getFirstFrame()), null);
handled = true; //glide now won't set the resource on the target itself
}
return handled;
}
});
builder.crossFade(500).into(mImageView);
答案 1 :(得分:1)
我希望这个有所帮助。
UIStoryboard * storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
// this any item in list you want navigate to
yourHomeViewController *home = (yourHomeViewController *) [storyboard instantiateViewControllerWithIdentifier:@"leid"];
yourSideMenuViewController *slidemenu = (yourSideMenuViewController *)[storyboard instantiateViewControllerWithIdentifier:@"MenuView"];
UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:home];
UINavigationController *smVC = [[UINavigationController alloc]initWithRootViewController:slidemenu];
// define rear and frontviewcontroller
SWRevealViewController *revealController = [[SWRevealViewController alloc]initWithRearViewController:smVC frontViewController:nav];
// make it as root
self.window.rootViewController = revealController;
答案 2 :(得分:0)
我们无法在App Delegate中调用RevealViewController。 您可以直接在ViewController for Front&amp;中添加它。后方。
答案 3 :(得分:0)
你有没有像这样声明和初始化revealViewController?
@interface AppDelegate ()
@property (strong, nonatomic) SWRevealViewController *revealViewController;
@end
/ * ... * /
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.revealViewController = /* ... init ... */;
/* ... your code here ... */
}
答案 4 :(得分:0)
我没有使用故事板但是这样做了:
SWRevealViewController *revealController = [[SWRevealViewController alloc] initWithRearViewController:menuViewController frontViewController:frontNavigationController];
SWRevealViewController *viewController = revealController;
答案 5 :(得分:0)
我想你可以把你的故事板中的SWRevealViewController中的开始指示器,给登录名VC一个名字
//if user is logged in - In login VC
[[NSUserDefaults standardUserDefaults] setValue:1 forKey:isLogged];
//In Appdelegate
if([[NSUserDefaults standardUserDefaults] valueForKey:isLogged] == 1)
{
NSLog(@"have data");
//Start straight into normal SWRevealVC
self.window.rootViewController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateInitialViewController];
}
else
{
//If not, make your root VC the login viewcontroller
UIViewController* rootController = [[UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]] instantiateViewControllerWithIdentifier:@"LoginViewController"];
self.window.rootViewController = rootController;
}