2014-04-19 2 views
0

Im 학교용 프로젝트를 만들고 있는데 테이블보기 컨트롤러에 문제가 있습니다. 다른 페이지에 연결할 단추를 추가하고 싶습니다. 그래서 연결되는 7 개의 표 셀 목록이 있습니다. 자세히보기 컨트롤러에, 거기에서 다른 페이지로 링크 할 것이라고 단추를 추가하고 싶지만 각 7 테이블 셀을 다른 페이지로 이동해야합니다, 미안 해요. 정말 감사하게 도와주세요.TableViewController 단추 연결

TableViewController.m

#import "tableViewController.h" 
#import "TableCell.h" 
#import "DetailViewController.h" 

@interface tableViewController() 

@end 

@implementation tableViewController 

- (id)initWithStyle:(UITableViewStyle)style 
{ 
self = [super initWithStyle:style]; 
if (self) { 
    // Custom initialization 
} 
return self; 
} 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 

// Uncomment the following line to preserve selection between presentations. 
// self.clearsSelectionOnViewWillAppear = NO; 

// Uncomment the following line to display an Edit button in the navigation bar for this view controller. 
// self.navigationItem.rightBarButtonItem = self.editButtonItem; 

_Title [email protected][@"Centrum Advance", @"Elite Whey Protein", @"USP LABS Jack3d", @"NitroCore 24", @"PHD Synergy ISO 7", @"REFLEX One Stop", @"MET-Rx G.C.M.O"]; 

[email protected][@"1C.jpg",@"2C.jpg",@"3C.jpg",@"4C.jpg",@"5C.jpg",@"6C.jpg",@"mets.jpg",]; 

[email protected][@"Not Reviewed",@"'I'm a big fan of whey protein becasue the dosing is simple, easy to consume, and usually a lot cheaper than pills. I use to use the regular old GNC 100% whey protein which was good to take after a workout, but I really wanted more from my supplements. Proto Whey had a lot of great reviews and I have to say, it worked pretty well for me.'",@"'Wow. This stuff is amazing. No fillers, the taste (lemon-lime) isn't overwhelming, and I can work out solid for 1.5 hours and still feel like a beast. I've taken NO-Xplode and Black Powder, and I find that Jack3d provides more energy, while something like Black Powder gives me more pump. This is why I mix a scoop of Black Powder and a scoop of Jack3d and get totally effed at the gym.I've come to notice that if I take jack3d later in the day, it really messes with my sleep, and I contribute that to the DMAA in it, which is a stimulant. I just finished a bottle and I notice my tolerance was going up. On days that I was taking just jack3d, since I like to mix it up, I moved up to 2 scoops towards the end of the bottle. So all in all, awesome for energy in the gym, only somewhat decent regarding pump. But I still give it a solid 9. I have yet to try out 1.M.R, which I will be getting next week, and can find out then which is better for me.BTW I didn't get a 'crash' that so many people speak of, this could be that maybe I am not just prone to the type of thing, and that I work out after I get off work, so 'crashing' really doesn't matter for me.'",@"Not Reviewed",@"'I had the double chocolate flavor and it was the BEST tasting stuff I've ever had. It was so good, sometimes I just took a serviing for breakfast if I was running short on time. The effectiveness was good too, and after finishing a tub of it, I noticed just about all of my lifts increased. I gained some great vascularity in my bi's, and my chest strength exploded. Honestly, for all of you who want to spend a little money and get a nice supplement...this is your winner. I am definitely gonna use this for a while until I get sick of the taste or see a new up-and-coming product. Only reason I give value a 5 is because I paid about $40 for the 2LB tub back in January.'",@"Not Reviewed",@"Not Reviewed",]; 

[email protected][@"1.2KG",@"3KG",@"2.7KG",@"3.9KG",@"5KG",@"6.4KG",@"0.5KG",]; 

[email protected][@"The perfect whey protein to aid weight loss or pack on lean muscle mass",@"Add some   serious muscle to your body without the fat!",@"24g of protein per scoop for just 112 calories and no sugars!",@"Premium Whey Isolate",@"Minimal carbohydrates and fats",@"The Only Way To Enjoy Whey Protein",@"27g of protein with each serving",]; 

} 

- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

#pragma mark - Table view data source 

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView 
{ 

// Return the number of sections. 
return 1; 
} 

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section 
{ 

// Return the number of rows in the section. 
return _Title.count; 
} 

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    static NSString *CellIdentifier = @"TableCell"; 
TableCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath]; 

// Configure the cell... 

    int row = [indexPath row]; 

    cell.TitleLabel.text = _Title[row]; 
    cell.ThumbImage.image = [UIImage imageNamed:_Images[row]]; 
cell.Review1.text = _Review[row]; 
cell.Size1.text = _Size[row]; 
cell.Does1.text = _Does[row]; 

    return cell; 
} 

-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender { 
    if([[segue identifier] isEqualToString:@"ShowDetails"]) { 
     DetailViewController *detailviewcontroller = [segue destinationViewController]; 

    NSIndexPath *myIndexPath = [self.tableView indexPathForSelectedRow]; 

    int row = [myIndexPath row]; 
    detailviewcontroller.DetailModal = @[_Title[row],_Images[row]]; 
    } 
} 
@end 

DetailViewController.m

#import "DetailViewController.h" 

@interface DetailViewController() 

@end 

@implementation DetailViewController 

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil 
{ 
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]; 
if (self) { 
    // Custom initialization 
} 
return self; 
} 

- (void)viewDidLoad 
{ 
[super viewDidLoad]; 
// Do any additional setup after loading the view. 
_TitleLabel.text = _DetailModal[0]; 
_ThumbImage.image = [UIImage imageNamed:_DetailModal [1]]; 

self.navigationItem.title = _DetailModal[0]; 

} 

- (void)didReceiveMemoryWarning 
{ 
[super didReceiveMemoryWarning]; 
// Dispose of any resources that can be recreated. 
} 

@end 

테이블 cell.m이 비어과 .H가

답변

0

가에 공개 @property 만들기 IBOutlets에 사용됩니다 DetailViewController - 각 개별 DetailViewController에서 버튼 대상을 설정하기 위해 prepareForSegue:sender: TableViewController에서 설정할 수 있습니다.

// DetailViewController.h 
@interface DetailViewController  
@property NSInteger nextPageId; // or whatever 

// TableViewController.m 
// prepareForSegue... 
detailviewcontroller.nextPageId = myIndexPath.row; // something like this 

// DetailViewController.m 
// viewDidLoad... 
[myButton addTarget:self action:@selector(myButtonHandlerMethod) forControlEvents:UIControlEventTouchUpInside]; 

-(void)myButtonHandlerMethod { 
    // code to present the next "page" based on self.nextPageId 
} 

사용자가 버튼을 도청 할 때 다른 방법을 설정 myButtonHandlerMethodaddTarget:action:forControlEvents: 메서드를 호출한다. UIButton이 DetailViewController Storyboard에 있으면 IBOutlet 속성을 만들고 버튼을 self.myButton으로 참조하십시오.

+0

도움을 주셔서 감사 드리며 무엇을해야할지 이해하기 시작했지만 버튼이 연결되는 방식을 이해하는 데 문제가 있습니다. – user3293705

+0

도움이 되나요? 이 사이트에서 적절한 도움을 얻으려면보다 구체적인 질문이 필요합니다 ... –

+0

다행히 도왔습니다. 수업 프로젝트를 계속 배우려면 [Matt Neuberg] (http://www.apeth.net/matt/default.html#cocoathings)의 두 권의 책을 확인하십시오 (실제로 iOS 6 버전의 책을 사용함). 작년에 내가 졸업 한 대학원 수업에 대해서.) –

관련 문제