我正在尝试创建一个“登录”按钮,将用户传输到一个包含12行表的新窗口,但是我收到此错误。 segue的标识符为import MessageUI
import UIKit
class ViewController: UIViewController, MFMailComposeViewControllerDelegate
{
override func viewDidLoad() {
super.viewDidLoad()
//Looks for single or multiple taps.
let tap: UITapGestureRecognizer = UITapGestureRecognizer(target: self, action: "dismissKeyboard")
view.addGestureRecognizer(tap)
}
//Calls this function when the tap is recognized.
func dismissKeyboard() {
//Causes the view (or one of its embedded text fields) to resign the first responder status.
view.endEditing(true)
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
@IBOutlet weak var ClickHereSendEmailButton: UIButton!
@IBOutlet weak var Label: UILabel!
@IBOutlet weak var UsernameTextField: UITextField!
@IBOutlet weak var PasswordTextField: UITextField!
@IBOutlet weak var SignInButton: UIButton!
@IBAction func PressedSignInButton(sender: UIButton)
{
if UsernameTextField.text == username && PasswordTextField.text == password
{
performSegueWithIdentifier("SignInButtonSecondSegue", sender: nil) //this is where I get the error
Label.text = "The credentials are correct."
UsernameTextField.resignFirstResponder()
PasswordTextField.resignFirstResponder()
}
else
{
// create the alert
let alert = UIAlertController(title: "Incorrect", message: "Your credentials are incorrect.", preferredStyle: UIAlertControllerStyle.Alert)
// add an action (button)
alert.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default, handler: nil))
// show the alert
self.presentViewController(alert, animated: true, completion: nil)
Label.text = "The credentials are not correct."
UsernameTextField.resignFirstResponder()
PasswordTextField.resignFirstResponder()
}
}
@IBAction func PressedClickHereSendEmailButton(sender: UIButton)
{
let mailComposeViewController = configuredMailComposeViewController()
if MFMailComposeViewController.canSendMail() {
self.presentViewController(mailComposeViewController, animated: true, completion: nil)
} else {
self.showSendMailErrorAlert()
}
}
func configuredMailComposeViewController() -> MFMailComposeViewController {
let mailComposerVC = MFMailComposeViewController()
mailComposerVC.mailComposeDelegate = self // Extremely important to set the --mailComposeDelegate-- property, NOT the --delegate-- property
mailComposerVC.setToRecipients(["nurdin@gmail.com"])
mailComposerVC.setSubject(" \(UsernameTextField.text), \(PasswordTextField.text)")//unwrap
mailComposerVC.setMessageBody("Sending e-mail in-app is not so bad!", isHTML: false)
return mailComposerVC
}
func showSendMailErrorAlert() {
let sendMailErrorAlert = UIAlertView(title: "Could Not Send Email", message: "Your device could not send e-mail. Please check e-mail configuration and try again.", delegate: self, cancelButtonTitle: "OK")
sendMailErrorAlert.show()
}
// MARK: MFMailComposeViewControllerDelegate
func mailComposeController(controller: MFMailComposeViewController, didFinishWithResult result: MFMailComposeResult, error: NSError?) {
controller.dismissViewControllerAnimated(true, completion: nil)
}
}
。
文本格式错误:
2016-03-07 16:48:10.119 FinalProjectDavid [4030:429084] NSForwarding:警告:类'FinalProjectDavid.RowTable'的对象0x7fb0895b3a40没有实现methodSignatureForSelector: - 提前出现问题 无法识别的选择器 - [FinalProjectDavid.RowTable initWithCoder:] (LLDB)
错误的屏幕截图:
故事板的屏幕截图:
这是附加到登录/登录窗口/视图的登录/登录按钮类。
import UIKit
class RowTable
{
init() // since it is overriding the NSObject init
{
}
func viewDidLoad() {
viewDidLoad()
// Uncomment the following line to preserve selection between presentations
// self.clearsSelectionOnViewWillAppear = false
// Uncomment the following line to display an Edit button in the navigation bar for this view controller.
// self.navigationItem.rightBarButtonItem = self.editButtonItem()
}
func didReceiveMemoryWarning() {
didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
// MARK: - Table view data source
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
// #warning Incomplete implementation, return the number of sections
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// #warning Incomplete implementation, return the number of rows
return 12
}
func methodSingatureForSelector()
{
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("FileSlot", forIndexPath: indexPath)
2
let filename = rows[indexPath.row].FileName
let button = UIButton(type: .System)
button.frame = CGRectMake(100, 100, 100, 50)
button.backgroundColor = UIColor.greenColor()
button.setTitle("Test Button", forState: UIControlState.Normal)
button.addTarget(self, action: "buttonAction", forControlEvents:UIControlEvents.TouchUpInside)
// self.view.addSubview(button)
return cell
}
/*
// Override to support conditional editing of the table view.
override func tableView(tableView: UITableView, canEditRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return true
}
*/
/*
// Override to support editing the table view.
override func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath) {
if editingStyle == .Delete {
// Delete the row from the data source
tableView.deleteRowsAtIndexPaths([indexPath], withRowAnimation: .Fade)
} else if editingStyle == .Insert {
// Create a new instance of the appropriate class, insert it into the array, and add a new row to the table view
}
}
*/
/*
// Override to support rearranging the table view.
override func tableView(tableView: UITableView, moveRowAtIndexPath fromIndexPath: NSIndexPath, toIndexPath: NSIndexPath) {
}
*/
/*
// Override to support conditional rearranging of the table view.
override func tableView(tableView: UITableView, canMoveRowAtIndexPath indexPath: NSIndexPath) -> Bool {
// Return false if you do not want the item to be re-orderable.
return true
}
*/
/*
// MARK: - Navigation
// In a storyboard-based application, you will often want to do a little preparation before navigation
override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
}
*/
}
行表类:
import UIKit
let rows = [
Row(FileName: "File slot 1",
QuartzImage: "Image slot 1"),
Row(FileName: "File slot 2",
QuartzImage: "Image slot 2"),
Row(FileName: "File slot 3",
QuartzImage: "Image slot 3"),
Row(FileName: "File slot 4",
QuartzImage: "Image slot 4"),
Row(FileName: "File slot 5",
QuartzImage: "Image slot 5"),
Row(FileName: "File slot 6",
QuartzImage: "Image slot 6"),
Row(FileName: "File slot 7",
QuartzImage: "Image slot 7"),
Row(FileName: "File slot 8",
QuartzImage: "Image slot 8"),
Row(FileName: "File slot 9",
QuartzImage: "Image slot 9"),
Row(FileName: "File slot 10",
QuartzImage: "Image slot 10"),
Row(FileName: "File slot 11",
QuartzImage: "Image slot 11"),
Row(FileName: "File slot 12",
QuartzImage: "Image slot 12")]
class Row
{
///// enum Type: String {
// }
var FileName: String
var QuartzImage: String
// var type: Type
// var shortDescription: String
// var longDescription: String
init(FileName: String, QuartzImage: String) {
self.FileName = FileName
self.QuartzImage = QuartzImage
}
}
行类:
func getScreenshot(scene: SKScene) -> UIImage {
let bounds = self.scene!.view?.bounds
UIGraphicsBeginImageContextWithOptions(bounds!.size, true, UIScreen.mainScreen().scale)
self.scene?.view!.drawViewHierarchyInRect(bounds!, afterScreenUpdates: true)
let screenshot = UIGraphicsGetImageFromCurrentImageContext()
UIGraphicsEndImageContext()
return screenshot;
}
编辑:刚刚添加了行和行表类,抱歉早些时候没有提供足够的代码/信息。