मेरे ऐप में मैं अपनी सूची से श्रेणी का चयन करने के लिए उपयोग करने योग्य उपयोग कर रहा हूं। मेरा कार्य है, जब कभी उपयोगकर्ता किसी सेल पर क्लिक या चयन करता है तो उसे चयनित दृश्य विवरण को अगले दृश्य (विवरण दृश्य) में देखने में सक्षम होना चाहिए। और जब वह आइटम को विस्तार से देखने में चुनता है तो उसे तालिका दृश्य में वापस जाने में सक्षम होना चाहिए और चयनित आइटम को rootivew नियंत्रक में देखने में सक्षम होना चाहिए।विवरण देखने से नियंत्रक को वापस देखने के लिए डेटा को कैसे पास किया जाए?
मैं तालिका दृश्य से विस्तार से देखने के लिए सही तरीके से नेविगेट करने में सक्षम हूं, लेकिन मैं उस आइटम को दिखाने में सक्षम नहीं हूं जिसे रूटव्यू कंट्रोलर को विस्तार से देखा गया है।
कृपया इस समस्या के साथ मेरी मदद करें।
छवि एक मेरा रूटव्यू नियंत्रक पृष्ठ है। उदाहरण के लिए : यदि उपयोगकर्ता @ "मेक" चुनते हैं तो वह @ "मेक" की सभी रिलीज़ श्रेणी को देख पाएंगे। अगले पृष्ठ में (कौन सा छवि 2)।
छवि मेरा विवरण पृष्ठ है।
और जब उपयोगकर्ता @ "abarth" का चयन करता है तो इसे रूटव्यू नियंत्रक पृष्ठ (जो पृष्ठ एक है) में प्रदर्शित होना चाहिए।
निम्नलिखितrootview नियंत्रक पेज के अपने कोड है:
- (void)viewDidLoad
{
self.car = [[NSArray alloc]initWithObjects:@"Make",@"Model",@"Price Min",@"Price Max",@"State",nil];
[super viewDidLoad];
}
-(NSInteger) numberOfSectionInTableView:(UITableView *)tableView
{
return 1;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [self.car count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *TextCellIdentifier = @"Cell";
UITableViewCell *cell =[tableView dequeueReusableCellWithIdentifier:TextCellIdentifier];
if (cell==nil)
{
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:TextCellIdentifier];
cell.accessoryType = UITableViewCellAccessoryNone;
cell.selectionStyle = UITableViewCellSelectionStyleNone;
}
cell.textLabel.text = [self.car objectAtIndex:[indexPath row]];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
return cell;
}
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (0 == indexPath.row)
{
NSLog(@"0");
self.detailcontroller.title = @"Make";
}
else if (1 == indexPath.row)
{
NSLog(@"1");
self.detailcontroller.title = @"Model";
}
else if (2 == indexPath.row)
{
NSLog(@"2");
self.detailcontroller.title = @"Price Min";
}
else if (3 == indexPath.row)
{
self.detailcontroller.title = @"Price Max";
}
else if (4 == indexPath.row)
{
NSLog(@"3");
self.detailcontroller.title = @"State";
}
[self.navigationController
pushViewController:self.detailcontroller
animated:YES];
}
following is my detail view page code:
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if ([self.title isEqualToString:@"Make"])
{
detail = [[NSArray alloc]initWithObjects:@"Any Make",@"Abarth",@"AC",@"ADAYER",@"Adelaide",@"ALFA ROMEO",@"ALLARD",@"ALPINE-RENAULT",@"ALVIS",@"ARMSTRONG",
@"ASTON MARTIN",@"AUDI",@"AUSTIN",@"AUSTIN HEALEY",@"Barossa",@"BEDFORD",
@"BENTLEY",@"BERTONE",@"BMW",@"BOLWELL",@"BRISTOL",@"BUICK",@"BULLET",
@"CADILLAC",@"CATERHAM",@"CHERY",@"CHEVROLET",@"CHRYSLER",@"CITROEN",
@"Country Central",@"CSV",@"CUSTOM",@"DAEWOO",@"DAIHATSU",@"DAIMLER",
@"DATSUN",@"DE TOMASO",@"DELOREAN",@"DODGE",@"ELFIN",@"ESSEX",
@"EUNOS",@"EXCALIBUR",@"FERRARI",nil];
if ([self.title isEqualToString:@"Abarth"])
{
detail = [[NSArray alloc]initWithObjects:@"HI", nil];
}
}
else if ([self.title isEqualToString:@"Model"])
{
detail = [[NSArray alloc]initWithObjects:@"Any Model", nil];
}
else if ([self.title isEqualToString:@"Price Min"])
{
detail = [[NSArray alloc]initWithObjects:@"Min",@"$2,500",
@"$5,000",
@"$7,500",
@"$10,000",
@"$15,000",
@"$20,000",
@"$25,000",
@"$30,000",
@"$35,000",
@"$40,000",
@"$45,000",
@"$50,000",
@"$60,000",
@"$70,000",
@"$80,000",
@"$90,000",
@"$100,000",
@"$500,000",
@"$1,000,000",nil];
}
else if ([self.title isEqualToString:@"Price Max"])
{
detail = [[NSArray alloc]initWithObjects:@"Max",
@"$2,500",
@"$5,000",
@"$7,500",
@"$10,000",
@"$15,000",
@"$20,000",
@"$25,000",
@"$30,000",
@"$35,000",
@"$40,000",
@"$45,000",
@"$50,000",
@"$60,000",
@"$70,000",
@"$80,000",
@"$90,000",
@"$100,000",
@"$500,000",
@"$1,000,000",nil];
}
else if ([self.title isEqualToString:@"State"])
{
detail = [[NSArray alloc]initWithObjects:@"Any State",
@"Australian Capital Territory",
@"New South Wales",
@"Northern Territory",
@"Queensland",
@"South Australia",
@"Tasmania",
@"Victoria",
@"Western Australia",nil];
}
[self.tableView reloadData];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [detail count];
}
- (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];
}
cell.textLabel.text = [detail objectAtIndex:
[indexPath row]];
cell.font = [UIFont systemFontOfSize:14.0];
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self.navigationController popViewControllerAnimated:YES];
}
धन्यवाद यह काम ठीक है। –