我正在爲學校製作一個項目,並且我在表格視圖控制器遇到問題,我想添加一個按鈕將其鏈接到另一個頁面,它真的是它,所以我有一個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用於IBOutlets
感謝您的幫助,我開始明白要做什麼,但仍然有問題了解按鈕將如何鏈接 – user3293705
這有幫助嗎?你真的需要一個更具體的問題在本網站獲得適當的幫助... –
很高興幫助。如果你想繼續學習你的課程項目(我實際上使用了本書的iOS 6版本),請查閱[Matt Neuberg](http://www.apeth.net/matt/default.html#cocoathings)的兩本書我去年參加了一個研究生班。) –