我目前正在尝试以Xcode5中的表格视图列表的形式制作线管理应用程序。我正在尝试将作为queue.h属性的mutablearray赋予也具有可变数组属性的queueviewcontroller。这样做的主要原因是稍后我将创建另一个nsmutablearray,其对象是队列数组,即它将是成员列表的列表。
由于某种原因(我已经搜索过Google和SO),这些应用程序可以正常编译,即没有问题,但是当我运行模拟器时,它只会产生黑屏。
我在编程方面相对较新,因此可以提供任何帮助。如果您需要其他信息,请告诉我。
Queue是一个NSObject子类,具有NSMutableArray属性,称为arrayQueue
故事板只是带有附加的tableviewcontroller(QueueViewController
)的navcontroller。
这是来自QueueViewController.m的代码
.h文件仅具有名为* queue的nsmutable数组的属性;
@implementation QueueViewController
{
Queue *list;
}
- (void)viewDidLoad
{
[super viewDidLoad];
list = [[Queue alloc]init];
QueueMember *member = [[QueueMember alloc]init];
member.name = @"adam";
member.rank = 1;
member.eta = 5;
[list.arrayQueue addObject:member];
member = [[QueueMember alloc]init];
member.name = @"bob";
member.rank = 2;
member.eta = 10;
[list.arrayQueue addObject:member];
member = [[QueueMember alloc]init];
member.name = @"cason";
member.rank = 3;
member.eta = 15;
[list.arrayQueue addObject:member];
QueueViewController *queueViewController = [[QueueViewController alloc]init];
queueViewController.queue = list.arrayQueue;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"QueueCell"];
QueueMember *member = (self.queue)[indexPath.row];
cell.textLabel.text = member.name;
cell.detailTextLabel.text = [NSString stringWithFormat:@"%d min", member.eta];
return cell;
}
整个应用程序委托
#import "AppDelegate.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
return YES;
}
- (void)applicationWillResignActive:(UIApplication *)application
{
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication *)application
{
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication *)application
{
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication *)application
{
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application
{
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end
最佳答案
您没有设置rootViewController
的window
。
编辑:
您可以在viewDidLoad
中创建数组。在viewDidLoad
中写:
list = [[Queue alloc]init];
QueueMember *member = [[QueueMember alloc]init];
member.name = @"adam";
member.rank = 1;
member.eta = 5;
[list.arrayQueue addObject:member];
member = [[QueueMember alloc]init];
member.name = @"bob";
member.rank = 2;
member.eta = 10;
[list.arrayQueue addObject:member];
member = [[QueueMember alloc]init];
member.name = @"cason";
member.rank = 3;
member.eta = 15;
[list.arrayQueue addObject:member];