Tôi đang phát triển ứng dụng Ipad có chế độ xem chia tách tùy chỉnh. Trong chế độ xem chủ, tôi có một tableViewController. Tôi thêm các mục trong mục này bằng nút thêm trong thanh điều hướng. Nút này được liên kết (tôi làm việc với bảng phân cảnh) với một phân đoạn popover đến một tableViewController khác có chứa một vài ô để nhập dữ liệu. Nút “lưu” loại bỏ chế độ xem cửa sổ bật lên một mục bổ sung trong danh sách chế độ xem chính. Điều tôi muốn làm tiếp theo là các ô mẫu chính của chế độ xem liên kết đến chế độ xem khác để cho phép người dùng chỉnh sửa mục đã chọn. Tôi muốn liên kết chế độ xem này với một phân đoạn cửa sổ bật lên (giống như nút thêm) và ở đó có problème: Tôi gặp sự cố màu đỏ từ xcode: Không thể biên dịch kết nối: => anchorView =>>.Hiển thị chế độ xem cửa sổ bật lên từ các ô mẫu thử động
Đây là mẫu mã của tôi hoạt động tốt. Tôi muốn làm khá giống nhau khi tôi chạm vào một ô để chỉnh sửa.
Bảng masterSplitView
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"assetCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
}
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
// Configure the cell...
AssetModel *myAssetModel = [self.arrayAsset objectAtIndex:indexPath.row];
cell.textLabel.text = myAssetModel.name;
// cell.textLabel.text = @"test";
return cell;
}
- (void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if([segue.identifier isEqualToString:@"addAssetSegue"]){
AddAssetTVC *addAssetTVC = segue.destinationViewController;
addAssetTVC.delegate = self;
UIStoryboardPopoverSegue* popoverSegue = (UIStoryboardPopoverSegue*)segue;
[addAssetTVC setPopoverController:[popoverSegue popoverController]];
}
}
- (void) theSaveButtonOnTheAddAssetTVCWasTapped:(AddAssetTVC *)controller{
[controller.navigationController popViewControllerAnimated:YES];
[self reloadCache];
[self.tableView reloadData];
[self viewDidLoad];
}
Và phương pháp tiết kiệm của view add:
- (IBAction)save:(id)sender{
[popoverController dismissPopoverAnimated:YES];
NSLog(@"Telling the ADDASSET Delegate that Save was tapped on the AddAssetTVC");
{...unrevelant coredata methods}
[self.delegate theSaveButtonOnTheAddAssetTVCWasTapped:self];
}
Cảm ơn bạn đã đọc,
Alexandre
Điều này thật tuyệt vời. Cảm ơn bạn. – user216661
Hoạt động tuyệt vời ngoại trừ 'popoverController' không được dùng nữa. Đã nhân bản mã trong câu trả lời dưới đây với 'popoverPresentationController' trong Swift. – Santhosh