【发布时间】:2013-11-12 05:07:50
【问题描述】:
我正在尝试合并这两个项目。
此时我只是试图将它们保存在单独的视图控制器中,并让缩略图选择器的功能在它自己的控制器中工作。
我收到了错误,如标题中所述,“在 'UIViewController *' 类型的对象上找不到属性 'images'”
错误来自 AppDelegate.m 文件:
#import "AppDelegate.h"
#import "ViewController.h"
@implementation AppDelegate
@synthesize window = _window;
@synthesize viewController = _viewController;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.viewController = [[UIViewController alloc] init];
NSArray *paths = [[NSBundle mainBundle] pathsForResourcesOfType:@"jpg" inDirectory:nil];
NSMutableArray *images = [NSMutableArray arrayWithCapacity:paths.count];
for (NSString *path in paths) {
[images addObject:[UIImage imageWithContentsOfFile:path]];
}
self.viewController.images = images;
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
return YES;
}
@end
这里是 AppDelegate.h:
#import <UIKit/UIKit.h>
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) UIViewController *viewController;
@end
我尝试过像这样声明一个属性:
@property (strong, nonatomic) UIImageView *images;
即使我煞费苦心地合并了这两个代码库,我似乎也无法解决这个问题。
这是我目前所处的 Xcode 项目:
【问题讨论】:
-
我不知道为什么这被否决了。我认为合并两个代码库(例如本例中来自 GitHub 的)对于 iOS 开发人员来说非常重要。
标签: ios iphone objective-c uiviewcontroller