ios - SWRevealViewController 错误。构建失败,但没有错误

标签 ios objective-c

首先,让我给你一个提示。我对 XCode (5) 和 Objective-C 比较熟悉。

但是,把我当作菜鸟,请帮帮我。

我正在尝试构建一个应用程序。我需要应用程序的所有 View 中的滑出菜单。

我使用 SwRevealViewController 类制作了一个虚拟项目。我还制作了两个滑出式菜单。它有效。

我尝试在我正在构建的应用程序中使用相同的方法。

但是我的构建失败了,没有错误和一个警告,这是我在以前的虚拟项目中遇到的......

我已经将 SwRevealViewController.h 导入到 AppDelegate.m 和 ViewController.m

我正在尝试使用 TableViewController 作为滑出菜单(它是空的,我还没有添加任何代码)。但是构建失败了。

编辑:
"错误如下..

"@synthesize of 'weak' property 只允许在 ARC 或 GC 模式下使用"

我在我的项目中使用 Core Data。而且我必须在我的应用程序中广泛使用网络服务。所以我禁用了ARC。 "

我也尝试用其他 View 替换 table,但结果相同。现在我被困住了。

我知道它与我的代码有关,但我找不到它。

我包括 AppDelegate.m 和 ViewController.m 的代码。

请检查并告诉我有什么问题。我在这里不知所措。

编辑:
"由于 Stack Overflow 限制,我无法上传图片。所以我在 tinypic 中上传了错误截图。这是 url。

http://tinypic.com/r/162vli/8 "

谢谢你的帮助。

AppDelegate.h

//  AppDelegate.h
//  IndianBloodBank
//
//  Created by Roshith Balendran on 8/5/14.
//  Copyright (c) 2014 Olympus. All rights reserved.
//


#import <UIKit/UIKit.h>

@class SWRevealViewController;

@interface AppDelegate : UIResponder <UIApplicationDelegate>

@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UINavigationController *UINV;
@property (strong, nonatomic) SWRevealViewController *splitMenu;

@property (readonly, strong, nonatomic) NSManagedObjectContext *managedObjectContext;
@property (readonly, strong, nonatomic) NSManagedObjectModel *managedObjectModel;
@property (readonly, strong, nonatomic) NSPersistentStoreCoordinator *persistentStoreCoordinator;

- (void)saveContext;
- (NSURL *)applicationDocumentsDirectory;


@end

AppDelegate.m
//
//  AppDelegate.m
//  IndianBloodBank
//
//  Created by Roshith Balendran on 8/5/14.
//  Copyright (c) 2014 Olympus. All rights reserved.
//

#import "AppDelegate.h"
#import "SWRevealViewController.h"
#import "HomePageViewController.h"
#import "SlideOutMenuTableViewController.h"
#import "SearchViewController.h"
#import "AboutUsViewController.h"
#import "SponsorsViewController.h"
#import "HowToDonateViewController.h"
#import "EmergencyViewController.h"

@implementation AppDelegate

@synthesize splitMenu,window,UINV;

@synthesize managedObjectContext = _managedObjectContext;
@synthesize managedObjectModel = _managedObjectModel;
@synthesize persistentStoreCoordinator = _persistentStoreCoordinator;

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    // Override point for customization after application launch.

    self.window = window;

    HomePageViewController *HPVC = [[HomePageViewController alloc]init];

    SlideOutMenuTableViewController *SOMTVC = SOMTVC = [[SlideOutMenuTableViewController alloc]init];


    UINavigationController *frontNavigationController = [[UINavigationController alloc]initWithRootViewController:HPVC];
    UINavigationController *rearNavigationController = [[UINavigationController alloc]initWithRootViewController:SOMTVC];

    SWRevealViewController *revealController= [[SWRevealViewController alloc]initWithRearViewController:rearNavigationController frontViewController:frontNavigationController];

    revealController.delegate=self;
    revealController.rightViewController = SOMTVC;
    self.splitMenu = revealController;
    self.window.rootViewController = self.splitMenu;

    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    return YES;
}

主页 View Controller .m
//
//  HomePageViewController.m
//  IndianBloodBank
//
//  Created by Roshith Balendran on 8/5/14.
//  Copyright (c) 2014 Olympus. All rights reserved.
//

#import "HomePageViewController.h"
#import "SWRevealViewController.h"
#import "AboutUsViewController.h"
#import "SponsorsViewController.h"
#import "HowToDonateViewController.h"

@interface HomePageViewController ()

@end

@implementation HomePageViewController

@synthesize btn1SearchBlood,btn2DonateNow;


- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
    // Do any additional setup after loading the view from its nib.

    [[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:0.055 green:0.055 blue:0.059 alpha:1]];

    self.navigationController.navigationBar.translucent=NO;

    SWRevealViewController *revealViewController = [self revealViewController];

    [revealViewController panGestureRecognizer];
    [revealViewController tapGestureRecognizer];

    UIBarButtonItem *menuButton = [[UIBarButtonItem alloc]initWithImage:[UIImage imageNamed:@"menu-icon"] style:UIBarButtonItemStyleBordered target:revealViewController action:@selector(revealToggle:)];

    self.navigationItem.leftBarButtonItem = menuButton;
}

最佳答案

解决方案很简单,我只需要打开 ARC。

SWRevealViewController 类的基本要求是启用 ARC。

在禁用 ARC 的情况下,您不能使用该类进行滑出导航。

我的坏人。以为我检查了启用 ARC 的错误。我的错。

因此,如果遇到此错误“@synthesize of 'weak' property is only allowed in ARC or GC Mode”,只需打开 ARC。

关于ios - SWRevealViewController 错误。构建失败,但没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25227957/

相关文章:

objective-c - 如何确定选择器的参数/关键字的数量

iphone - 为什么 UITableView 调用 UIScrollView 的委托(delegate)方法?

iphone - NSSortDescriptor 和 NSPredicate 用于排序和过滤

javascript - 如何使用 PWA 在 IOS 设备中显示主屏幕提示

ios - 手动安装 Firebase 时出错 (Swift)

ios - 根据 View 更改自定义 UITableViewCell 高度

Objective-C setFrame Swift 等效项

iphone - 如何在 viewDidLoad 中引用 UIButton?

ios - 在 iOS 设备上,如何检查日期时间设置

ios - 如何知道哪个 View 被推送到某个 View