2011-04-23 4 views
1

에서 작업 테이블을 볼 세그먼트 controlller를 사용하여 내 표는 변경 선택된 세그먼트에 따라 ... 여기 세그먼트 제어가 나는 새로운 BIE입니다 아이폰

코드 ... 그리고 문제는 때를하지 어떤 segment..it 나에게 아무것도 표시되지 않을 선택 ..

- (void)viewDidLoad { 

segArrayOne = [[NSMutableArray alloc] initWithObjects:@"A",@"B",@"C",nil]; 
segArrayTwo = [[NSMutableArray alloc] initWithObjects:@"1",@"2",@"3",@"4",nil]; 
segArrayThree = [[NSMutableArray alloc] initWithObjects:@"A1",@"A2",@"A3",@"A4",@"A5",nil]; 
dummyArray = [[NSMutableArray alloc] init]; 

tableDummy = [[UITableView alloc] initWithFrame:CGRectMake(0,80,320,400) style:UITableViewStyleGrouped]; 
tableDummy.delegate = self; 
tableDummy.dataSource = self; 
// 
dummyArray=segArrayOne; 
[self.view addSubview:tableDummy]; 
tableDummy.scrollEnabled=NO; 

//[tableDummy release]; 
[segmentedController addTarget:self action:@selector(buttonPressed:) forControlEvents:UIControlEventValueChanged]; 


[super viewDidLoad]; 

}

-(IBAction)buttonPressed:(id)sender{ 

selectedSegment = [segmentedController selectedSegmentIndex]; 

switch (selectedSegment) { 
    case 0: 
     dummyArray=segArrayOne; 
     break; 
    case 1: 
     dummyArray=segArrayTwo; 
     break; 
    case 2: 
     dummyArray=segArrayThree; 

     break; 
    default: 
     //dummyArray=segArrayOne; 

     break; 
} 


NSLog(@"%@",dummyArray); 

}

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

}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section { 
NSLog(@"%@",dummyArray); 

return [dummyArray count]; 
//return @""; 

}

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

static NSString *CellIdentifier = @"Cell"; 

UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 
if (cell == nil) { 
    cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
     } 
cell.textLabel.text = [dummyArray objectAtIndex:indexPath.row]; 

return cell; 

} 당신이 원하는 경우

-(IBAction)buttonPressed:(id)sender 

의 끝 또는 경우에

답변

1

전화 [tableDummy reloadData] 코드를 복제하고 a에서 reloadData를 사용하지 않으려 고합니다. 기본 경우.

+0

감사합니다 ... 작동했습니다 .......... –

관련 문제