- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个 TableView 和一个与导航 Controller 连接的详细 View Controller ,当我按下它时,它会转到详细 View Controller ,它在我的详细 View Controller 中工作正常我有一个按钮我想要在按下该按钮后隐藏我单击的特定单元格。我正在使用 Swift 3 Xcode 8。
表格 View :
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource{
var delegate = SimpleProtocol.self
@IBOutlet weak var tableview: UITableView!
var cars = ["Ferrari", "Lamborghini", "Aston Martin", "Buggati", "Tesla"]
var carslogo = ["images-7", "photo", "astonmartinlogo", "buggatilogo", "Tesla-Motors-logo-3"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
tableview.dataSource = self
tableview.delegate = self
tableview.contentInset = UIEdgeInsets(top: 0,left: 0,bottom: 0,right: 0)
}
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(true)
tableview.reloadData()
}
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 150.0
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return cars.count
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let indexPath = tableView.indexPathForSelectedRow!
self.performSegue(withIdentifier: "ss", sender: indexPath)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "ss" {
let details = segue.destination as! DetailViewController
let indexPath = sender as! IndexPath
details.view1 = cars[indexPath.row]
details.view3 = UIImage(named: cars[indexPath.row])!
if indexPath.row == 0 {
details.view2 = ("Ferrari N.V. pronounced ferˈrari is an Italian sports car manufacturer based in Maranello. Founded by Enzo Ferrari in 1939 out of Alfa Romeo's race division as Auto Avio Costruzioni, the company built its first car in 1940. However the company's inception as an auto manufacturer is usually recognized in 1947, when the first Ferrari-badged car was completed.In 2014, Ferrari was rated the world's most powerful brand by Brand Finance. In May 2012 the 1962 Ferrari 250 GTO became the most expensive car in history, selling in a private transaction for US$38.1 million to American communications magnate Craig McCaw.Fiat S.p.A. acquired 50 percent of Ferrari in 1969 and expanded its stake to 90 percent in 1988.[5] In October 2014 Fiat Chrysler Automobiles announced its intentions to separate Ferrari S.p.A. from FCA; as of the announcement FCA owned 90 percent of Ferrari. The separation began in October 2015 with a restructuring that established Ferrari N.V. (a company incorporated in the Netherlands) as the new holding company of the Ferrari group and the subsequent sale by FCA of 10 percent of the shares in an IPO and concurrent listing of common shares on the New York Stock Exchange. Through the remaining steps of the separation, FCA's interest in Ferrari's business was distributed to shareholders of FCA, with 10 percent continuing to be owned by Piero Ferrari. The spin-off was completed on 3 January 2016.")
} else if indexPath.row == 1 {
details.view2 = ("The Lamborghini Aventador is a mid-engined sports car produced by the Italian manufacturer Lamborghini.Launched on 28 February 2011 at the Geneva Motor Show, five months after its initial unveiling in Sant'Agata Bolognese, the vehicle, internally codenamed LB834, was designed to replace the then-decade-old Murciélago as the new flagship model.Soon after the Aventador unveiling, Lamborghini announced that it had already sold over 12 of the production vehicles, with deliveries starting in the second half of 2011. By March 2016, Lamborghini had already built 5,000 Aventadors, taking five years to achieve this milestone.")
} else if indexPath.row == 2 {
details.view2 = ("Aston Martin Lagonda Limited is a British manufacturer of luxury sports cars and grand tourers. It was founded in 1913 by Lionel Martin and Robert Bamford. Steered from 1947 by David Brown it became associated with expensive grand touring cars in the 1950s and 1960s, and with the fictional character James Bond following his use of a DB5 model in the 1964 film Goldfinger. Their sports cars are regarded as a British cultural icon. Aston Martin has held a Royal Warrant as purveyor of motorcars to HRH the Prince of Wales since 1982.Headquarters and the main production site are in Gaydon, Warwickshire, England, on the site of a former RAF V Bomber airbase. One of Aston Martin's recent cars was named after the 1950s Vulcan Bomber. Aston Martin has diversified to speed boats, and real estate development.")
} else if indexPath.row == 3 {
details.view2 = ("Automobiles Ettore Bugatti was a French car manufacturer of high-performance automobiles, founded in 1909 in the then German city of Molsheim, Alsace by Italian-born Ettore Bugatti. Bugatti cars were known for their design beauty (Ettore Bugatti was from a family of artists and considered himself to be both an artist and constructor[clarification needed]) and for their many race victories. Famous Bugattis include the Type 35 Grand Prix cars, the Type 41 Royale, the Type 57 Atlantic and the Type 55 sports car. The death of Ettore Bugatti in 1947 proved to be the end for the marque, and the death of his son Jean Bugatti in 1939 ensured there was not a successor to lead the factory. No more than about 8,000 cars were made. The company struggled financially, and released one last model in the 1950s, before eventually being purchased for its airplane parts business in the 1960s. In the 1990s, an Italian entrepreneur revived it as a builder of limited production exclusive sports cars. Today, the name is owned by German automobile manufacturing group Volkswagen.")
} else if indexPath.row == 4 {
details.view2 = ("Tesla, Inc. (formerly named Tesla Motors) is an American automaker, energy storage company, and solar panel manufacturer based in Palo Alto, California.[7] The company was initially founded in 2003 by Martin Eberhard and Marc Tarpenning, although the company also considers Elon Musk, JB Straubel, and Ian Wright as its co-founders. The company specializes in electric cars, lithium-ion battery energy storage, and, through their SolarCity subsidiary, residential solar panels. Tesla first gained widespread attention following production of the Roadster, the first electric sports car, in February 2008. The companys second vehicle, the Model S, an electric luxury sedan, debuted in June 2012 and is built at the Tesla Factory in California. The Model S has been the world s best-selling plug-in electric car for two years in a row, 2015 and 2016. Its global sales achieved the 150,000 unit milestone in November 2016, four years and five months after its introduction. As of December 2016, the Model S ranks as the world's all-time second best-selling plug-in after the Nissan Leaf.")
}
}
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableview.dequeueReusableCell(withIdentifier: "Cell", for: indexPath) as! TableViewCell
let name = cars[indexPath.row]
let logonmae = carslogo[indexPath.row]
cell.label.text = name
cell.logoimage.image = UIImage(named: logonmae)
cell.image1.image = UIImage(named: name)
return cell
}
}
详细 View Controller :
class Model: Object {
dynamic var carname : String?
dynamic var detail : String?
}
class DetailViewController: UIViewController {
let object = ViewController()
let ob = TableViewCell()
var model : Model?
let realm = try! Realm()
@IBOutlet weak var detailimage: UIImageView!
@IBOutlet weak var detaillabel: UILabel!
@IBOutlet weak var detailtextfield: UITextView!
@IBAction func button(_ sender: Any) {
self.model = Model()
model!.carname = self.detaillabel.text!
model!.detail = self.detailtextfield.text!
if let data = model {
try! self.realm.write {
self.realm.add(data)
}
}
}
var view1 = ""
var view2 = String()
var view3 = UIImage()
override func viewDidLoad() {
super.viewDidLoad()
detaillabel.text = view1
detailtextfield.text = view2
detailimage.image = view3
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
}
最佳答案
据我推断,您的详细 View Controller 上有一个按钮,按下该按钮后您想要删除当前详细 View Controller 所在的单元格。
您的方法应该是当您在 detail view controller
中时,您应该传递您来自的单元格的 index
。
现在,当用户单击按钮时,您可以使用一个 bool
来检查或传回您的 TableView 。
当用户单击按钮并返回表格时,您实际上应该同时传递索引和标志,然后在您的 tableview 类的viewwillappear
中,您可以根据标志检查是否应该删除所选索引,如果索引设置为删除,那么您应该简单地使用索引从 cars
和 cars-logo array
和reload
你的tableview。
这些可以改进很多,但这应该足以作为起点。
关于ios - 在 swift 3 中删除 TableView 的特定选择单元格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45592551/
我知道如何通过iPhone开发创建sqlite数据库、向其中插入数据、删除行等,但我试图以编程方式删除整个数据库本身,但没有得到任何帮助。请有人指导我如何通过代码从设备中删除/删除整个 sqlite
请帮助指导如何在 Teradata 中删除数据库。 当我运行命令DROP DATABASE database_name时,我收到错误消息: *** Failure 3552 Cannot DROP d
Azure 警报规则的删除命令似乎不起作用,尝试了下面的方法,它返回状态为无内容,并且警报未被删除 使用的命令Remove-AzAlertRule -ResourceGroup "RGName"-Na
我在 flex 搜索中为大约50000个视频建立了索引,但是当它达到52000左右时,所有数据都被删除。嗯,这对我来说真的很奇怪,我没有为ES设置任何Heap大小或最小或最大大小的内存大小,因此它们没
我正在处理的问题是表单错误“输入由字母、数字、下划线或连字符组成的有效‘slug’。” 以下是我的表单字段验证: def clean_slug(self): slug = self.c
阅读文档,我希望 $("#wrap2").remove(".error") 从 中删除所有 .error 元素#wrap2。然而看看这个 JSFiddle: http://jsfiddle.net/h
嗨,我第一次尝试发现 laravel 我从 laravel 4.2 开始,我刚刚创建了一个新项目,但我误以为我写了这样的命令行 composer create-project laravel/lara
我已经在网上搜索了很长一段时间,但我找不到如何完全删除 apache 2.4 。 使用: Windows 7 c:\apache24\ 我已经尝试了所有命令,但没有任何效果。 httpd -k shu
可能是一个简单的答案,所以提前道歉(最少的编码经验)。 我正在尝试从任何列中删除具有特定字符串(经济 7)的任何行,并且一直在尝试离开此线程: How to drop rows from pandas
有几种方法可以删除/移除 vector 中的项目。 我有一个指针 vector ,我需要在类的析构函数中删除所有指针。 什么是最有效/最快甚至最安全的方式? // 1º std::for_each(v
我安装了一个 VNC 服务器并在某处阅读了我必须安装 xinetd 的信息。稍后我决定删除 VNC 服务器,所以我也删除了 xinetd。似乎 xinetd 删除了一些与 plesk 相关的文件,如果
我制作了一个从我们的服务器下载视频的应用。问题是: 当我取消下载时,我打电话: myAsyncTask.cancel(true) 我注意到,myAsyncTask 并没有在调用取消时停止...我的 P
是否可以在使用DELETE_MODEL删除模型之前检查模型是否存在我试图避免在尝试删除尚未创建的模型时收到错误消息。基本上我正在寻找对应的: DROP TABLE IF EXISTS 但对于模型。 最
我已经有了这个代码: 但它仍然会生成一个表行条目。 我想做的是,当输入的数量为0时,表行将被删除。请耐心等待,因为我是 php 和 mySQL 编码新手。 最佳答案 您忘记执行查询。应该是 $que
在 SharePoint 中,如果您删除/修改重复日历条目的单次出现,则不会真正删除/修改任何内容 - 相反,会创建一个新条目,告诉 SP 对于特定日期,该事件不存在或具有新参数. 因此,这可以通过删
在 routes.php 中我有以下路由: Route::post('dropzone', ['as' => 'dropzone.upload', 'uses' => 'AdminPhotoContr
在我的应用程序中,我正在尝试删除产品。当我第一次删除产品时,它会成功并且 URL 更改为/remove_category/15。我正在渲染到同一页面。现在,当我尝试删除另一个产品时,网址更改为/rem
这个问题被问了很多次,但给出的答案都是 GNU sed 特定的。 sed -i '' "/${FIND}/,+2d""$FILE" 给出“预期的上下文地址”错误。 有人可以给我一个例子,说明如何使用
在使用 V3 API 时,我找不到任何方法来删除和清理 Google map 。 我已经在 AJAX 站点中运行它,所以我想完全关闭它而无需重新加载页面。 我希望有一个 .unload() 或 .de
是否可以创建一个 Azure SQL 数据库用户来执行以下操作: 针对所有表和 View 进行 SELECT 创建/更改/删除 View 但用户不应该不拥有以下权限: 针对任何表或 View 插入/更
我是一名优秀的程序员,十分优秀!