2012-08-01 2 views

답변

0

당신과 같은 음식 이름의 배열이 가정 :

NSArray *foodArr = [NSArray arrayWithObjects:@"Chicken",@"Cheese",@"Hamburger"] 

을하고 제목이 "치즈"(인덱스 1에있는 객체)가되고 싶어요, 당신은 내에서있는 NSString을 확보해야 당신이 근래 경우,

self.navigationController.title = foodTitle; 
+0

당신은 또한'UIViewController'가'UINavigationController' 내에서 포장되어야한다 말할 수 있습니다. 건배 :) –

+0

참, 고마워. :) – Stavash

0

당신은이 작업을 수행 할 수 있습니다 배열 :

NSString *foodTitle = [foodArr objectAtIndex:1]; 

는 해당 문자열로 제목을 설정할 수 있습니다 당신이 title 속성을 가진 객체의 배열이있는 경우

yourViewController.title = [self.myNameArray objectAtIndex:selectedIndex]; 

: 당신이 내비게이션 바와 UINavigationController가를 사용하는 경우

yourViewController.title = [[self.myObjectArray objectAtIndex:selectedIndex] title]; 
0

당신은 쉽게 따라 할 수있는 : 전자 문자열 배열 할

-(void) viewDidLoad { 

    self.navigationItem.title = [NSString stringWithString:@"%@",[yourTitles objectAtIndex:yourIndex]; 

} 

사용하지 않으면 제목을 제공 할 UILabel을 수동으로 추가하고 같은 작업을 수행합니다.

-(void) viewDidLoad { 

    [titleLabel setText:[NSString stringWithString:@"%@",[yourTitles objectAtIndex:yourIndex]]; 

} 
0

예 아주 간단한

//Assuming you are displaying food item in tableView 
//vController is class object which is going to be pushed on navigation stack 
//Put this line in didSelectRowAtIndexPath method 

yourViewControllerObject.title = [foodItemArray objectAtIndex:indexPath.row];