複数の選択リストを表示するための単純なカスタム デリゲートを作成しようとしています (さまざまなオンライン チュートリアル、stackoverflow、Apple doc を参照した後) が、デリゲートを使用するクラスで、デリゲートを設定する行が無限ループに陥ります。私がそれを実行するとき。
ここでソースコードを共有しました https://bitbucket.org/ikosmik/uilistviewcontroller/src/ddfcd140b52e6e59d84e58d34d601f8f850145a1/UIList?at=master
UIListViewController (プロトコルを宣言している場所) https://bitbucket.org/ikosmik/uilistviewcontroller/src/ddfcd140b52e6e59d84e58d34d601f8f850145a1/UIList/UIListViewController.h?at=master
そしてView_Exporterと呼ばれるUIViewControllerでデリゲートを使用しようとしています
#import <UIKit/UIKit.h>
#import "UIListViewController.h"
@interface View_Exporter : UIViewController <UIListViewDelegate, UIListViewDataSource>
@property (nonatomic, strong) IBOutlet UIView *viewForList;
@property (nonatomic, strong) UIListViewController *listViewController;
@end
View_Exporter.m
#import "View_Exporter.h"
@implementation View_Exporter
@synthesize arraySelectedList;
@synthesize viewForList;
@synthesize listViewController;
#pragma mark - UIListViewController Methods
-(NSArray *) itemsForList {
NSLog(@"View_Exporter itemsForList");
NSArray *array = [NSArray arrayWithObjects:@"Server", @"Memory", nil];
return array;
}
- (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.
self.listViewController = [[UIListViewController alloc] initWithNibName:@"UIListViewController" bundle:nil];
self.listViewController.listViewDelegate = self;
//[self.viewForList addSubview:self.listViewController.view];
self.listViewController.listViewDataSource = self;
}
@end
しかし、viewDidLoad のこの行は、コードを実行すると無限にループするようです:
self.listViewController.listViewDelegate = self;
これが無限にループするのはなぜですか?これについて昨日から頭を悩ませています。どこが間違っているのかわかりません。誰か助けてくれませんか?