Dynamic 在ios 6中向第二个动态单元格添加单独的标识符?
项目的第一个场景是动态单元视图,如下所示。我给了它一个标识符,以便在代码中引用它 我在代码中创建了第二个分组部分,该部分按预期显示。当用户单击第一个单元格时,它会移动到一个特定场景,但是第二个单元格也会移动到同一场景 如何给第二个单元格一个单独的标识符,以便创建一个到不同场景的序列?第二个单元格没有出现在故事板中,所以我不能这样设置 目前我对这一场景的代码如下:Dynamic 在ios 6中向第二个动态单元格添加单独的标识符?,dynamic,uitableview,ios6,segue,identifier,Dynamic,Uitableview,Ios6,Segue,Identifier,项目的第一个场景是动态单元视图,如下所示。我给了它一个标识符,以便在代码中引用它 我在代码中创建了第二个分组部分,该部分按预期显示。当用户单击第一个单元格时,它会移动到一个特定场景,但是第二个单元格也会移动到同一场景 如何给第二个单元格一个单独的标识符,以便创建一个到不同场景的序列?第二个单元格没有出现在故事板中,所以我不能这样设置 目前我对这一场景的代码如下: #import "ViewController.h" @interface ViewController () @end @i
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
@synthesize testLocation;
- (void)viewDidLoad
{
testLocation = @"Washington, Dulles";
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
}
#pragma mark - Table View Methods
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView; // Default is 1 if not implemented
{
return 2;
}
- (NSString *)tableView:(UITableView *)tableView titleForHeaderInSection:(NSInteger)section; // fixed font style. use custom view (UILabel) if you want something different
{
if (section == 0) {
return @"Choose Test Location:";
}
else {
return @"Choose Test Type:";
}
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section;
{
if (section == 0) {
return 1;
}
else {
return 1;
}
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath;
{
UITableViewCell *serverLocCell = [tableView dequeueReusableCellWithIdentifier:@"serverLocation"];
switch (indexPath.section) {
case 0:
serverLocCell.textLabel.text = testLocation;
serverLocCell.detailTextLabel.text = @"Change";
break;
case 1:
serverLocCell.textLabel.text = @"Speed Test";
serverLocCell.detailTextLabel.text = @"Change";
break;
default:
break;
}
return serverLocCell;
}
@end
在情节提要编辑器中,创建要使用的两个分段,但要使它们从一个控制器分段到下一个控制器,而不是从表视图分段。在控制器级别执行此操作。为每个序列指定一个特定且不同的名称
实现
didSelectRowAtIndexPath
,以便您知道用户何时选择表中的单元格。根据索引路径中的节(或行),以编程方式启动segue。谢谢@Andrew,我已经按照你说的做了,现在将寻找如何以编程方式启动segue的方法。Dan,这里有一些提示。如果你需要更多,请告诉我。