2013-08-05 2 views
0

해결하기 어려운 문제가 있습니다.행 선택시 새 UIView 열기

위 표의 셀을 클릭하면 새 UITableView을 열어야합니다.

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { 

ChoiceChampionViewController *choiceChampionViewController = [[ChoiceChampionViewController alloc] initWithNibName:@"ChoiceChampionViewController" bundle:nil]; 

NSString * ind = @"....."; 
NSString * number = ..; 
ind = [ind stringByReplacingOccurrencesOfString:@"XX" withString:number]; 
[[NSUserDefaults standardUserDefaults] setValue:number forKey:@"Region"]; 
choiceChampionViewController.url = ind; 
[self.view addSubview: choiceChampionViewController.view]; 
} 

다음 ChoiceChampionViewController 구조화 :

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
    if (self) {   
     champion = [[NSMutableArray alloc] init ]; 
     self.navigationItem.title = @"Here is some text to make the navBar big"; 
    } 
    return self; 
} 

- (void)viewDidLoad 
{ 
    [super viewDidLoad]; 

    dispatch_async(kBgQueue, ^{ 
     NSData* data = [NSData dataWithContentsOfURL:[NSURL URLWithString:url]]; 
     [self performSelectorOnMainThread:@selector(fetchedData:) withObject:data waitUntilDone:YES]; 
    }); 
} 

- (void)fetchedData:(NSData *)responseData { 
    Method for process data 
} 


- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 
    return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 
    return [champion count]; 
} 

- (UITableViewCell *)tableView:(UITableView *)atableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { 

    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
    if (cell == nil) { 
     cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier]; 
    } 
    League * app = [[League alloc] init]; 
    app = [champion objectAtIndex:[indexPath row]]; 
    cell.textLabel.text = app.title; 

    return cell; 
} 

을하지만 날이 오류주는 유지 : [ChoiceChampionViewController있는 tableView : cellForRowAtIndexPath을 :] 해제 된 경우에 송신 메시지. 우리가 도와 줄 수 있습니까?

cellForRowAtIndexPath: 방법이 울부 짖는 소리 구조를 사용 .. :

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath;{ 

    ChoiceChampionViewController * choiceChampionViewController = [[ChoiceChampionViewController alloc]initWithNibName:@"ChoiceChampionViewController" bundle:nil]; 
    UIBarButtonItem *_backButton = [[UIBarButtonItem alloc] initWithTitle:@"Back" style:UIBarButtonItemStyleDone target:nil action:nil]; 
    self.navigationItem.backBarButtonItem = _backButton; 
    [_backButton release], 
    _backButton = nil; 

    [self.navigationController pushViewController:choiceChampionViewController animated:YES]; 
    [choiceChampionViewController release]; 
} 

UPDATE ... 울부 짖는 소리와 같은 새로운 UIViewController에 이동에 대한 pushViewController의 사용과 UITableViewController 또는 UIViewController 새로운 것을

+0

나는 당신이 어디 있니? 그것을 확인하십시오 – IKKA

+0

"챔피언"배열에 개체가 있는지 여부를 확인할 수 있습니까? – IKKA

+0

ARC를 사용합니다. "챔피언"배열에는 50 개의 개체가 있습니다. – user1319267

답변

0

공개 .

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{ 
    static NSString *CellIdentifier = @"Cell"; 

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:nil]; 
    if (cell == nil) { 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:CellIdentifier] autorelease]; 
    } 
    League * app = [[League alloc] init]; 
    app = [champion objectAtIndex:[indexPath row]]; 
    cell.textLabel.text = app.title; 

    return cell; 
} 
+0

아무 일도 발생하지 않습니다. 나는 테이블을 누르고 뷰를 변경하지 않습니다. 응용 프로그램을 처음 시작할 때만 표시되는 설정보기입니다. 내 AppDelegate에서 첫 번째보기가 이렇게 호출되었습니다. ChoiceViewController * settingsVC = [[ChoiceViewController alloc] init]; 는 [self.window.rootViewController presentViewController : settingsVC 애니메이션 : YES 완료^{} 내있는 navigationController는 rootViewController이'MasterViewController * masterViewController 같이 UINavigationBarController' '로 설정을 위해 그것 AppDelegate에에서, 새로운 제어기로 푸시되지 이유 – user1319267

+0

닐 그게이며 = [[[MasterViewController alloc] initWithNibName : @ "MasterViewController_iPhone"번들 : nil] autorelease]; self.navigationController = [[UINavigationController alloc] initWithRootViewController : masterViewController]; self.window.rootViewController = self.navigationController; ' –

+0

하지만 내 AppDelegate에서 rootViewController는 입니다. self.window.rootViewController = self.tabBarController; 내 앱에 하나의 탭이 있기 때문에 – user1319267