How can i use same navigation Controller to go different view controller from different Cells?
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[[tableView cellForRowAtIndexPath:indexPath] setSelected:NO animated:YES];
if(indexPath.section==0)
{
if([array1 objectAtIndex:0])
{
BirthDateController *yeniSayfa=[[BirthDateController alloc] init];
yeniSayfa.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
开发者_StackOverflow中文版 [self presentModalViewController:yeniSayfa animated:YES];
[yeniSayfa release];
}
}
}
I want only the first one the first item in the array1 to go this BirthDate modal view but now all the first section is using this modalview.Can anybody help me for making only the first cell of the first section opens this modal view.
I want only the first one the first item in the array1 to go this BirthDate modal view but now all the first section is using this modalview.
If I understand correctly, you mean the first row in the first section. Then, change your condition like this:
if( indexPath.section == 0 && indexPath.row == 0 ) {
The resulting code would look like this:
if( indexPath.section == 0 && indexPath.row == 0 ) {
BirthDateController *yeniSayfa=[[BirthDateController alloc] init];
yeniSayfa.modalTransitionStyle=UIModalTransitionStyleFlipHorizontal;
[self presentModalViewController:yeniSayfa animated:YES];
[yeniSayfa release];
}
The inner if
:
if([array1 objectAtIndex:0])
does make sense to me. It will evaluate to true unless array1
is nil
(or raise an exception). objectAtIndex:
can not return nil
because a NSArray
can not store nil
values and if the index is beyond the end of the array, it raises a NSRangeException
.
You also need to check for row in the if statement.
if (indexPath.section == 0 && indexPath.row == 0) {
精彩评论