我创建了一个csv文件并尝试通过电子邮件发送它.显示发送邮件的窗口,但不填充电子邮件正文,也没有附加文件.应用程序挂起此屏幕:
按钮"取消"不起作用.在控制台中出现几秒钟后:
viewServiceDidTerminateWithError: Error Domain=_UIViewServiceInterfaceErrorDomain Code=3 "The operation couldn’t be completed. (_UIViewServiceInterfaceErrorDomain error 3.)" UserInfo=0x7f8409f29b50 {Message=Service Connection Interrupted}
<MFMailComposeRemoteViewController: 0x7f8409c89470> timed out waiting for fence barrier from com.apple.MailCompositionService
Run Code Online (Sandbox Code Playgroud)
有我的代码:
func actionSheet(actionSheet: UIActionSheet!, clickedButtonAtIndex buttonIndex: Int) {
if buttonIndex == 0 {
println("Export!")
var csvString = NSMutableString()
csvString.appendString("Date;Time;Systolic;Diastolic;Pulse")
for tempValue in results { //result define outside this function
var tempDateTime = NSDate()
tempDateTime = tempValue.datePress
var dateFormatter = NSDateFormatter()
dateFormatter.dateFormat = "dd-MM-yyyy"
var tempDate = dateFormatter.stringFromDate(tempDateTime)
dateFormatter.dateFormat = "HH:mm:ss"
var tempTime …Run Code Online (Sandbox Code Playgroud) ios uidocumentinteraction mfmailcomposer uiactivityviewcontroller
这是示例代码:
import UIKit
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
@IBAction func showEmail(sender : AnyObject) {
var emailTitle = "Test Email"
var messageBody = "This is a test email body"
var toRecipents = ["a.nakhimov@gmail.com"]
var mc: MFMailComposeViewController = MFMailComposeViewController()
mc.mailComposeDelegate = self
mc.setSubject(emailTitle)
mc.setMessageBody(messageBody, isHTML: false)
mc.setToRecipients(toRecipents)
self.presentViewController(mc, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
func mailComposeController(controller:MFMailComposeViewController, didFinishWithResult result:MFMailComposeResult, error:NSError) {
switch result …Run Code Online (Sandbox Code Playgroud) 在我的应用程序中,我在数组的基础上填写表.该表使用自定义UITableViewCell.一切正常,桌子就满了.然后我将搜索显示控制器添加到我的UITableViewController,没有写代码来处理搜索,只需添加控制器.当您运行该应用程序时,该表仍然填充.但如果我尝试单击搜索栏,我会收到错误:
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'unable to dequeue a cell with identifier CitiesListCell - must register a nib or a class for the identifier or connect a prototype cell in a storyboard'
我尝试在UITableViewController行添加到我的viewDidLoad函数:
self.tableView.registerClass(MyCell.classForCoder(), forCellReuseIdentifier: kCellIdentifier)
启动应用程序并立即收到错误:
fatal error: unexpectedly found nil while unwrapping an Optional value
排队 cell.cellMyCity.text = cellText
我究竟做错了什么?
这是我的Custom UITableViewCell类:
import UIKit
class MyCell: UITableViewCell {
@IBOutlet var cellMyImage: UIImageView
@IBOutlet var cellMyCity: UILabel
@IBOutlet var cellMyCountry: UILabel
@IBOutlet var cellMyTemp: UILabel …Run Code Online (Sandbox Code Playgroud) 如何在Apple的新语言中实现它:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
for (UIView *view in self.view.subviews)
[view resignFirstResponder];
}
Run Code Online (Sandbox Code Playgroud)
我试过这样做.但键盘不会消失:
override func touchesBegan(touches: NSSet, withEvent event: UIEvent) {
super.touchesBegan(touches, withEvent: event)
self.view.resignFirstResponder()
}
Run Code Online (Sandbox Code Playgroud) 我有一个功能:
func parseJSON3(inputData: NSData) -> NSArray {
var tempDict: (id:Int, ccomments:Int, post_date:String, post_title:String, url:String) = (id: 0, ccomments: 0, post_date: "null", post_title: "null", url: "null")
var resultArray: (id:Int, ccomments:Int, post_date:String, post_title:String, url:String)[] = []
var error: NSError?
var jsonDictionary: NSDictionary = NSJSONSerialization.JSONObjectWithData(inputData, options: NSJSONReadingOptions.MutableContainers, error: &error) as NSDictionary
var firstArray = jsonDictionary.objectForKey("locations") as NSArray
for dict in firstArray {
tempDict.id = dict.valueForKey("ID") as Int
tempDict.ccomments = dict.valueForKey("ccomments") as Int
tempDict.post_date = dict.valueForKey("post_date") as String
tempDict.post_title = dict.valueForKey("post_title") as String
tempDict.url …Run Code Online (Sandbox Code Playgroud) 我需要建议如何继续.
如何稍微调暗主视图并显示一些忙碌指示,在某些动作的持续时间内,然后删除调光?
用Swift语言.
谢谢!
UPD:在Objective-C中,我之前使用过这样的东西:
UIView *dimView = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 460)];
dimView.backgroundColor = [UIColor blackColor];
dimView.alpha = 0.5f;
dimView.tag = 1111;
dimView.userInteractionEnabled = NO;
[self.view addSubview:dimView];
Run Code Online (Sandbox Code Playgroud)
我们如何在Swift中执行此代码?
对不起任何代码行的问题很抱歉.如果可能的话,我需要建议如何继续.
用Swift语言.
让我们假设有一个带有两个控制器的应用程序 - UITableViewController以嵌入式NavigationController为主.在表中选择一行时,将打开UIViewController,其中显示有关所选值的详细信息.
是否可以这样做?应用程序启动时,以编程方式模拟表中第一行的选择,并立即显示UIViewController有关所选值的详细信息.而从这个控制器可以返回到UITableViewController通过NavigationController.
我再一次道歉并提前感谢你!
这是示例代码:
import UIKit
import MessageUI
class ViewController: UIViewController, MFMailComposeViewControllerDelegate {
@IBAction func showEmail(sender : AnyObject) {
var emailTitle = "Test Email"
var messageBody = "This is a test email body"
var toRecipents = ["a.nakhimov@gmail.com"]
var mc: MFMailComposeViewController = MFMailComposeViewController()
mc.mailComposeDelegate = self
mc.setSubject(emailTitle)
mc.setMessageBody(messageBody, isHTML: false)
mc.setToRecipients(toRecipents)
self.presentViewController(mc, animated: true, completion: nil)
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of …Run Code Online (Sandbox Code Playgroud) objective-c uiviewcontroller swift ios8 mfmailcomposeviewcontroller
这是带UITableViewController和的示例代码CoreData.主文件MainTableViewController.swift:
import UIKit
import CoreData
class MainTableViewController: UITableViewController {
var results:AddrBook[]=[]
init(style: UITableViewStyle) {
super.init(style: style)
}
init(coder aDecoder: NSCoder!) {
super.init(coder: aDecoder)
}
override func viewDidLoad() {
super.viewDidLoad()
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
override func viewDidAppear(animated: Bool) {
let request = NSFetchRequest(entityName: "Person")
request.returnsObjectsAsFaults = false
let appDelegate:AppDelegate = (UIApplication.sharedApplication().delegate as AppDelegate)
let context:NSManagedObjectContext = appDelegate.managedObjectContext
results = context.executeFetchRequest(request, error: nil) as AddrBook[]
self.tableView.reloadData()
}
override func numberOfSectionsInTableView(tableView: UITableView?) -> Int …Run Code Online (Sandbox Code Playgroud) 我有一个样本plist文件,favCities.plist.这是我的示例代码:
override func viewDidLoad() {
super.viewDidLoad()
let path = NSBundle.mainBundle().pathForResource("favCities", ofType: "plist")
var plistArray = NSArray(contentsOfFile: path) as [Dictionary<String, String>]
var addDic: Dictionary = ["ZMV": "TEST", "Name": "TEST", "Country": "TEST"]
plistArray += addDic
(plistArray as NSArray).writeToFile(path, atomically: true)
var plistArray2 = NSArray(contentsOfFile: path)
for tempDict1 in plistArray2 {
var tempDict2: NSDictionary = tempDict1 as NSDictionary
var cityName: String = tempDict2.valueForKey("Name") as String
var cityZMV: String = tempDict2.valueForKey("ZMV") as String
var cityCountry: String = tempDict2.valueForKey("Country") as String
println("City: \(cityName), ZMV: \(cityZMV), …Run Code Online (Sandbox Code Playgroud) swift ×9
ios8 ×8
uitableview ×3
ios ×2
objective-c ×2
uiview ×2
core-data ×1
mfmailcomposeviewcontroller ×1
nsarray ×1
nsdictionary ×1
plist ×1
tuples ×1
xcode6 ×1