我的应用中有一个using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.EntityFrameworkCore;
using CompanyApp.Data;
using CompanyApp.Model;
namespace CompanyApp.Controllers
{
public class CompanyController : Controller
{
private readonly CompanyContext _context;
public CompanyController(ManagementContext context)
{
_context = context;
}
// GET: Companies
public async Task<IActionResult> Index()
{
return View(await _context.Companies.ToListAsync());
}
// GET: Company/Details/5
public async Task<IActionResult> Details(int? id)
{
if (id == null)
{
return NotFound();
}
var company = await _context.Companies
.Include(s => s.CompanyEmployee)
.ThenInclude(e => e.Employee)
.AsNoTracking()
.SingleOrDefaultAsync(m => m.CompanyID == id);
if (company == null)
{
return NotFound();
}
return View(company);
}
// GET: Company/Create
public IActionResult Create()
{
return View();
}
// POST: Company/Create
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Create([Bind("CompanyID,CompanyWebsite,CompanyPresident")] Company company)
{
if (ModelState.IsValid)
{
_context.Add(company);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
return View(company);
}
// GET: Company/Edit/5
public async Task<IActionResult> Edit(int? id)
{
if (id == null)
{
return NotFound();
}
var company = await _context.Companies.SingleOrDefaultAsync(m => m.CompanyID == id);
if (company == null)
{
return NotFound();
}
return View(company);
}
// POST: Companies/Edit/5
// To protect from overposting attacks, please enable the specific properties you want to bind to, for
// more details see http://go.microsoft.com/fwlink/?LinkId=317598.
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Edit(int id, [Bind("CompanyID,CompanyWebsite,CompanyPresident")] Company company)
{
if (id != company.CompanyID)
{
return NotFound();
}
if (ModelState.IsValid)
{
try
{
_context.Update(company);
await _context.SaveChangesAsync();
}
catch (DbUpdateConcurrencyException)
{
if (!CompanyExists(company.CompanyID))
{
return NotFound();
}
else
{
throw;
}
}
return RedirectToAction("Index");
}
return View(company);
}
// GET: Company/Delete/5
public async Task<IActionResult> Delete(int? id)
{
if (id == null)
{
return NotFound();
}
var company = await _context.Companies
.SingleOrDefaultAsync(m => m.CompanyID == id);
if (company == null)
{
return NotFound();
}
return View(company);
}
// POST: Company/Delete/5
[HttpPost, ActionName("Delete")]
[ValidateAntiForgeryToken]
public async Task<IActionResult> DeleteConfirmed(int id)
{
var company = await _context.Companies.SingleOrDefaultAsync(m => m.CompanyID == id);
_context.Companies.Remove(company);
await _context.SaveChangesAsync();
return RedirectToAction("Index");
}
private bool CompanyExists(int id)
{
return _context.Companies.Any(e => e.CompanyID == id);
}
}
}
。在UITabViewController
的第三个ViewController
上,用户可以转到UITabViewController
之外的单独ViewController
。但是,当它们向后移动时,UITabViewController
条不显示。所以,我把一个segue回到UITabView
,但现在它只是转到UITabViewController
的第一页而不是第三页。我在单独的UITabViewController
文件上有一个prepareForSegue(),告诉它转到第3页,但它似乎没有工作。这是我的代码:
ViewController
有谁知道如何解决这个问题?任何帮助都会非常感激。非常感谢提前!!
干杯,Theo
答案 0 :(得分:0)
你试过了吗?
@IBAction func backTouched(sender: AnyObject) {
dismissViewControllerAnimated(true, completion: nil)
}
在你要解雇的控制器中将其链接起来?或者使用func unWindToSegue(segue:...)方法?