开发者

how to pass a selected array from a uitable to another uitable

开发者 https://www.devze.com 2023-03-24 00:32 出处:网络
Can anybody 开发者_开发知识库guide me how to do something like this: I managed to do the 1st & the last screen, I need to put in another 1 in between them.

Can anybody 开发者_开发知识库guide me how to do something like this:

how to pass a selected array from a uitable to another uitable

I managed to do the 1st & the last screen, I need to put in another 1 in between them.

Is there any tutorial that i can learn from ?

thanks alot :)


Create a uinavigationcontroller with uitableview should help you achieve your goal here.

There are many tutorials for that. A quick google search landed me this. Basically you can use a single navigation controller and a single uitableviewcontroller class and create add the items to them. If you are unable to grasp the concepts from that tutorial add a comment here on where you are stuck. I will try to edit this post accordingly.


in screen1:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
 {
    Screen2 *screen2 = [[Screen2 alloc]initWithNibName:.......];
    screen2.itsArray = [[NSMutableArray alloc] init];       
    if(indexPath.row == 1)
       {
         screen2.itsArray = yourArrayForScreen2_FirstRow;
       }
    else if(indexPath.row == 2){
         screen2.itsArray = yourArrayForScreen2_SecondRow;
      }else{ ...... }
   [self.viewController pushViewCOntroller .....];
 }

in screen2: NSMutableArray *itsArray; @property and @snynthesize

now use itsArray as you need it. in screen2, do the same as in screen1 for the screen3


What you need is basically an NSMutableArray with NSMutableArray

for eg.

obj1,obj2,obj3...nil is the dict. in your example

NSMutableArray *middleScreenElement1 = [NSMutableArray arrayWithObjects:obj1,obj2,obj3...,nil];

NSMutableArray *middleScreenElement2 = [NSMutableArray arrayWithObjects:obj1,obj2,obj3...,nil];

NSMutableArray *middleScreenElement3 = [NSMutableArray arrayWithObjects:obj1,obj2,obj3...,nil];

NSMutableArray *firstScreen = [NSMutableArray arrayWithObjects:middleScreenElement1,middleScreenElement2,middleScreenElement3];

In your 1st TableView,add the following method..

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
   NSMutableArray *middleScreenArray = (NSMutableArray*)[firstScreen objectAtIndex:indexPath.row];
    NextTableViewController *nTVC = [NextTableViewController alloc]initWithArray:middleScreenArray];
}

now you can use the array to populate your table view just like the middle screen.

**note you have to create an initWithArray:(NSMutableArray*)array method in your middleScreenViewController

Hope it helps.. :)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号