I have a TableView each row will open the same screen but with different locations for the views.
I want the images to open up on each view in a random way.
i have a random method which takes care of that but i am not sure how to call this method upon selection of a row in the TableView - This same method should be called for every row. At this moment i am randomizing each view with a button - after the view loads i need to press the button and then the images are r开发者_如何学Pythonandomized.
Is there a way to call this method upon a selection of a row in the TableView?
-(IBAction) randomizeLocations:(UIButton*)sender {
for (MyView* myv in rndArry)
{
int x;
x = generateRandomNumber();
while (usedRnd[x] == 1)
{
x = generateRandomNumber();
}
myv.frame = rndArryloc[x];
usedRnd[x] = 1;
}
int i;
for (i=0; i<8; i++)
{
usedRnd[i] = 0;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
switch (indexPath.row) {
case 0:
{
OneViewController* ovc = [[OneViewController alloc] initWithNibName:@"OneViewController" bundle:nil];
[self.navigationController pushViewController:ovc animated:YES];
// ???? WHAT SHOULD I PUT HERE ????
[ovc release];
}
break;
ect....
Thanks for the great and fast answers -
i have read again and again and finally figured out what i needed to do. As Holger wrote u did call the method in the ViewDidLoad and everything is working now.
Thanks again - This Forum Rules :)
精彩评论