我有一个应用程序,可以填充表格,并在选定的单元格中推送web视图。我有两个问题
这是我的密码。任何帮助都是必要的。
表视图
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad {
[self setupArray];
[super viewDidLoad];
// Do any additional setup after loading the view.
}
-(void)setupArray {
webAddress = [[NSMutableDictionary alloc]init];
[webAddress setObject:@"http://www.google.com.au" forKey:@"one"];
[webAddress setObject:@"http://www.finddrinkdine.com.au" forKey:@"Two"];
[webAddress setObject:@"http://www.kingsgroversl.com.au" forKey:@""three"];
[webAddress setObject:@"http://www.yahoo.com.au" forKey:@"Four"];
[webAddress setObject:@"http://www.scu.edu.au" forKey:@"Five"];
[webAddress setObject:@"http://www.whitenow.com.au" forKey:@"Six"];
menuItems = [webAddress allKeys];
}
-(NSInteger) tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [webAddress count];
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *simpleTableIdentifier = @"cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
cell.textLabel.text = [menuItems objectAtIndex:indexPath.row];
return cell;
}细节视图
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
return self;
}
-(void)viewWillAppear:(BOOL)animated {
NSURL *url = [NSURL URLWithString:webAddress];
NSURLRequest *req = [NSURLRequest requestWithURL:url];
[viewWeb loadRequest:req];
[super viewWillAppear:animated];
}发布于 2013-09-25 04:10:26
webAddress allKeys;将返回NSArray,但字典中不维护排序,因此它将返回随机数组。
发布于 2013-09-25 06:25:50
menuItems = [webAddress allKeys];将上述代码替换为排序数组或
menuItems = @[@"one", @"two",...];https://stackoverflow.com/questions/18995536
复制相似问题