這是一個奇怪的問題,並且直觀地反映了tableview是如何工作的,但是我有一個在tableview中創建3個單元格的數組。由於我們目前正在進行一個測試版,我們只需要用戶在點擊第一個單元格時繼續使用,而不需要使用另外兩個單元格。Segue Tableview當只有一個單元格被點擊時
這裏是我們的tableview的一些代碼
import UIKit
class TableViewController: UITableViewController {
let locationManager = CLLocationManager()
//Store Array of Images
var imageArray = ["riverparkplace","mayfair","jamesonhouse",]
//Array of Image Names
var textArray = ["River Park Place", "MayFair", "Jameson House"]
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
locationManager.requestAlwaysAuthorization()
if KCSUser.activeUser() == nil {
print("User Not Logged In")
performSegueWithIdentifier("jobsiteTOLogin", sender: nil)
} else {
//user is logged in and will be loaded on first call to Kinvey
var currentusername = KCSUser.activeUser().givenName
print("User named:\(currentusername) has logged in ")
}
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell!
//cell.textLabel?.text = textArray[indexPath.row]
let imageView = cell.viewWithTag(1) as! UIImageView
imageView.image = UIImage(named: imageArray[indexPath.row])
let textLabel2 = cell.viewWithTag(2) as! UILabel
textLabel2.text = textArray[indexPath.row]
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return imageArray.count
}
//On Click
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) {
}
//Buttons
@IBAction func logoutButton(sender: AnyObject) {
if KCSUser.activeUser() == nil{
//User is not logged in
print("Cant log out user since they are not logged in!!")
}else{
KCSUser.activeUser().logout()
print("User Logged out")
performSegueWithIdentifier("jobsiteTOLogin", sender: nil)
}
}
}
正如你可以看到我只想認爲,如果應用程序沒有采取任何措施Segue公司,當你點擊「riverrockplace」如果你點擊任何東西它是確定但如果它返回彈出式通知會更好。
也在這個階段,當我繼續,我不需要與我的數據。